From 43fc0e8df2a5972454be51bede82191a4031fea6 Mon Sep 17 00:00:00 2001 From: Shidong Wang Date: Tue, 5 Oct 2021 16:22:39 +0800 Subject: [PATCH] fix(lang#vim): fix `lang#vim` layer key bindings --- autoload/SpaceVim/layers/lang/vim.vim | 18 ++++++++++++++++++ autoload/SpaceVim/layers/treesitter.vim | 1 + autoload/SpaceVim/lsp.vim | 4 +--- doc/SpaceVim.txt | 10 ++++++++++ 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/autoload/SpaceVim/layers/lang/vim.vim b/autoload/SpaceVim/layers/lang/vim.vim index 09e32c8aa..04435cbc0 100644 --- a/autoload/SpaceVim/layers/lang/vim.vim +++ b/autoload/SpaceVim/layers/lang/vim.vim @@ -33,6 +33,15 @@ " SPC l f open exception trace " g d jump to definition " < +" > +" key binding Description +" SPC l e rename symbol +" SPC l d show document +" K show document +" < +" +" If the lsp layer is enabled for vim script, the following key bindings can +" be used: if exists('s:auto_generate_doc') finish @@ -135,6 +144,15 @@ function! s:language_specified_mappings() abort \ . string(function('s:helpversion_cursor')) . ', [])', \ 'echo helpversion under cursor', 1) call SpaceVim#mapping#space#langSPC('nmap', ['l','f'], 'call exception#trace()', 'tracing exceptions', 1) + if SpaceVim#layers#lsp#check_server('vimls') || SpaceVim#layers#lsp#check_filetype('vim') + nnoremap K :call SpaceVim#lsp#show_doc() + + call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'd'], + \ 'call SpaceVim#lsp#show_doc()', 'show_document', 1) + call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'e'], + \ 'call SpaceVim#lsp#rename()', 'rename symbol', 1) + endif + endfunction function! s:eval_cursor() abort diff --git a/autoload/SpaceVim/layers/treesitter.vim b/autoload/SpaceVim/layers/treesitter.vim index 24610e45e..affa14242 100644 --- a/autoload/SpaceVim/layers/treesitter.vim +++ b/autoload/SpaceVim/layers/treesitter.vim @@ -19,4 +19,5 @@ endfunction function! SpaceVim#layers#treesitter#health() abort call SpaceVim#layers#treesitter#plugins() + return 1 endfunction diff --git a/autoload/SpaceVim/lsp.vim b/autoload/SpaceVim/lsp.vim index 75e729c34..f18d5f40d 100644 --- a/autoload/SpaceVim/lsp.vim +++ b/autoload/SpaceVim/lsp.vim @@ -24,9 +24,7 @@ if (has('nvim-0.5.0') && s:NVIM_VERSION.is_release_version()) || has('nvim-0.6.0 \ ) endfunction function! SpaceVim#lsp#show_doc() abort - lua require('lsp.plugin') - \ .client.request('textDocument/hover', - \ {}, require('spacevim.lsp').hover_callback) + lua vim.lsp.buf.hover() endfunction function! SpaceVim#lsp#go_to_def() abort lua vim.lsp.buf.definition() diff --git a/doc/SpaceVim.txt b/doc/SpaceVim.txt index 6710229e3..149119ecb 100644 --- a/doc/SpaceVim.txt +++ b/doc/SpaceVim.txt @@ -4257,6 +4257,16 @@ The following key bindings will be added when this layer is loaded: g d jump to definition < +> + key binding Description + SPC l e rename symbol + SPC l d show document + K show document +< + +If the lsp layer is enabled for vim script, the following key bindings can be +used: + ============================================================================== LANG#VUE *SpaceVim-layers-lang-vue*