mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-13 18:25:42 +08:00
feat(lang#javascript): add more lsp key bindings
1. SPC l x: show references 2. SPC l s: show line diagnostics 3. SPC l w l: list workspace folder 4. SPC l w a: add workspace folder 5. SPC l w r: remove workspace folder 6. add `g D` for type def jumping
This commit is contained in:
parent
6ad6022d96
commit
773aa07b46
@ -45,6 +45,20 @@
|
|||||||
" SPC l s l send current line
|
" SPC l s l send current line
|
||||||
" SPC l s s send selection text
|
" SPC l s s send selection text
|
||||||
" <
|
" <
|
||||||
|
" If the lsp layer is enabled for javascript, the following key
|
||||||
|
" bindings can be used:
|
||||||
|
" >
|
||||||
|
" key binding Description
|
||||||
|
" g D jump to type definition
|
||||||
|
" SPC l e rename symbol
|
||||||
|
" SPC l x show references
|
||||||
|
" SPC l s show line diagnostics
|
||||||
|
" SPC l d show document
|
||||||
|
" K show document
|
||||||
|
" SPC l w l list workspace folder
|
||||||
|
" SPC l w a add workspace folder
|
||||||
|
" SPC l w r remove workspace folder
|
||||||
|
" <
|
||||||
"
|
"
|
||||||
|
|
||||||
let s:format_on_save = 0
|
let s:format_on_save = 0
|
||||||
@ -103,7 +117,7 @@ function! SpaceVim#layers#lang#javascript#config() abort
|
|||||||
\ 'opt': ['-'],
|
\ 'opt': ['-'],
|
||||||
\ })
|
\ })
|
||||||
call SpaceVim#mapping#space#regesit_lang_mappings('javascript',
|
call SpaceVim#mapping#space#regesit_lang_mappings('javascript',
|
||||||
\ function('s:on_ft'))
|
\ function('s:language_mappings'))
|
||||||
|
|
||||||
if SpaceVim#layers#lsp#check_filetype('javascript')
|
if SpaceVim#layers#lsp#check_filetype('javascript')
|
||||||
call SpaceVim#mapping#gd#add('javascript',
|
call SpaceVim#mapping#gd#add('javascript',
|
||||||
@ -149,7 +163,7 @@ function! SpaceVim#layers#lang#javascript#config() abort
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:on_ft() abort
|
function! s:language_mappings() abort
|
||||||
nnoremap <silent><buffer> <F4> :ImportJSWord<CR>
|
nnoremap <silent><buffer> <F4> :ImportJSWord<CR>
|
||||||
nnoremap <silent><buffer> <Leader>ji :ImportJSWord<CR>
|
nnoremap <silent><buffer> <Leader>ji :ImportJSWord<CR>
|
||||||
nnoremap <silent><buffer> <Leader>jf :ImportJSFix<CR>
|
nnoremap <silent><buffer> <Leader>jf :ImportJSFix<CR>
|
||||||
@ -175,12 +189,25 @@ function! s:on_ft() abort
|
|||||||
|
|
||||||
|
|
||||||
if SpaceVim#layers#lsp#check_filetype('javascript')
|
if SpaceVim#layers#lsp#check_filetype('javascript')
|
||||||
|
\ || SpaceVim#layers#lsp#check_server('tssserver')
|
||||||
nnoremap <silent><buffer> K :call SpaceVim#lsp#show_doc()<CR>
|
nnoremap <silent><buffer> K :call SpaceVim#lsp#show_doc()<CR>
|
||||||
|
nnoremap <silent><buffer> gD :<C-u>call SpaceVim#lsp#go_to_typedef()<Cr>
|
||||||
|
|
||||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'd'],
|
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'd'],
|
||||||
\ 'call SpaceVim#lsp#show_doc()', 'show_document', 1)
|
\ 'call SpaceVim#lsp#show_doc()', 'show-document', 1)
|
||||||
|
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'x'],
|
||||||
|
\ 'call SpaceVim#lsp#references()', 'show-references', 1)
|
||||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'e'],
|
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'e'],
|
||||||
\ 'call SpaceVim#lsp#rename()', 'rename symbol', 1)
|
\ 'call SpaceVim#lsp#rename()', 'rename-symbol', 1)
|
||||||
|
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 's'],
|
||||||
|
\ 'call SpaceVim#lsp#show_line_diagnostics()', 'show-line-diagnostics', 1)
|
||||||
|
let g:_spacevim_mappings_space.l.w = {'name' : '+Workspace'}
|
||||||
|
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'w', 'l'],
|
||||||
|
\ 'call SpaceVim#lsp#list_workspace_folder()', 'list-workspace-folder', 1)
|
||||||
|
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'w', 'a'],
|
||||||
|
\ 'call SpaceVim#lsp#add_workspace_folder()', 'add-workspace-folder', 1)
|
||||||
|
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'w', 'r'],
|
||||||
|
\ 'call SpaceVim#lsp#remove_workspace_folder()', 'remove-workspace-folder', 1)
|
||||||
else
|
else
|
||||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'd'], 'TernDoc',
|
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'd'], 'TernDoc',
|
||||||
\ 'show document', 1)
|
\ 'show document', 1)
|
||||||
|
@ -2931,6 +2931,20 @@ This layer also provides REPL support for javascript, the key bindings are:
|
|||||||
SPC l s l send current line
|
SPC l s l send current line
|
||||||
SPC l s s send selection text
|
SPC l s s send selection text
|
||||||
<
|
<
|
||||||
|
If the lsp layer is enabled for javascript, the following key bindings can be
|
||||||
|
used:
|
||||||
|
>
|
||||||
|
key binding Description
|
||||||
|
g D jump to type definition
|
||||||
|
SPC l e rename symbol
|
||||||
|
SPC l x show references
|
||||||
|
SPC l s show line diagnostics
|
||||||
|
SPC l d show document
|
||||||
|
K show document
|
||||||
|
SPC l w l list workspace folder
|
||||||
|
SPC l w a add workspace folder
|
||||||
|
SPC l w r remove workspace folder
|
||||||
|
<
|
||||||
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
Loading…
x
Reference in New Issue
Block a user