From da40455f5cd12fc6fee86e92dd101562e8e1e69f Mon Sep 17 00:00:00 2001 From: Shidong Wang Date: Sun, 10 Oct 2021 23:16:11 +0800 Subject: [PATCH] feat(lang#rust): add more lsp key bindings for rust --- autoload/SpaceVim/layers/lang/rust.vim | 36 ++++++++++++++++++++++---- doc/SpaceVim.txt | 17 +++++++++++- 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/autoload/SpaceVim/layers/lang/rust.vim b/autoload/SpaceVim/layers/lang/rust.vim index 96e683cd4..745c8100a 100644 --- a/autoload/SpaceVim/layers/lang/rust.vim +++ b/autoload/SpaceVim/layers/lang/rust.vim @@ -10,7 +10,8 @@ "" " @section lang#rust, layers-lang-rust " @parentsection layers -" This layer is for Rust development. +" `lang#rust` layers provides rust programming language support for SpaceVim. +" This layers includes syntax highlighting, code runner, REPL for rust. " " Requirements: " @@ -81,6 +82,20 @@ " SPC l s s send selection text " < " +" If the lsp layer is enabled for python, 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 +" < if exists('s:racer_cmd') finish @@ -182,12 +197,23 @@ function! s:language_specified_mappings() abort if SpaceVim#layers#lsp#check_filetype('rust') nnoremap K :call SpaceVim#lsp#show_doc() + nnoremap gD :call SpaceVim#lsp#go_to_typedef() + call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'd'], - \ 'call SpaceVim#lsp#show_doc()', 'show documentation', 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#lsp#rename()', 'rename symbol', 1) - call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'u'], - \ 'call SpaceVim#lsp#references()', 'show references', 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 nmap K (rust-doc) call SpaceVim#mapping#space#langSPC('nmap', ['l', 'd'], diff --git a/doc/SpaceVim.txt b/doc/SpaceVim.txt index 9bbda816b..27514941a 100644 --- a/doc/SpaceVim.txt +++ b/doc/SpaceVim.txt @@ -3782,7 +3782,8 @@ This layer also provides REPL support for ruby, the key bindings are: ============================================================================== LANG#RUST *SpaceVim-layers-lang-rust* -This layer is for Rust development. +`lang#rust` layers provides rust programming language support for SpaceVim. +This layers includes syntax highlighting, code runner, REPL for rust. Requirements: @@ -3859,6 +3860,20 @@ This layer also provides REPL support for rust, the key bindings are: SPC l s s send selection text < +If the lsp layer is enabled for python, 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 +< ============================================================================== LANG#SCALA *SpaceVim-layers-lang-scala*