1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-02 22:40:06 +08:00

fix(rust): fix rust lsp check

close https://github.com/SpaceVim/SpaceVim/issues/4762
This commit is contained in:
wsdjeg 2023-07-02 22:12:49 +08:00
parent c9cd11ff21
commit 37e6806081

View File

@ -110,7 +110,9 @@ endif
function! SpaceVim#layers#lang#rust#plugins() abort function! SpaceVim#layers#lang#rust#plugins() abort
let plugins = [] let plugins = []
call add(plugins, [g:_spacevim_root_dir . 'bundle/rust.vim', {'merged' : 0}]) call add(plugins, [g:_spacevim_root_dir . 'bundle/rust.vim', {'merged' : 0}])
if !SpaceVim#layers#lsp#check_filetype('rust') if !spacevim#layers#lsp#check_filetype('rust')
\ && !spacevim#layers#lsp#check_server('rls')
\ && !spacevim#layers#lsp#check_server('rust_analyzer')
call add(plugins, ['racer-rust/vim-racer', {'merged' : 0}]) call add(plugins, ['racer-rust/vim-racer', {'merged' : 0}])
endif endif
return plugins return plugins
@ -145,6 +147,8 @@ function! SpaceVim#layers#lang#rust#config() abort
call add(g:spacevim_project_rooter_patterns, 'Cargo.toml') call add(g:spacevim_project_rooter_patterns, 'Cargo.toml')
if SpaceVim#layers#lsp#check_filetype('rust') if SpaceVim#layers#lsp#check_filetype('rust')
\ || SpaceVim#layers#lsp#check_server('rls')
\ || SpaceVim#layers#lsp#check_server('rust_analyzer')
call SpaceVim#mapping#gd#add('rust', function('SpaceVim#lsp#go_to_def')) call SpaceVim#mapping#gd#add('rust', function('SpaceVim#lsp#go_to_def'))
else else
call SpaceVim#mapping#gd#add('rust', function('s:gotodef')) call SpaceVim#mapping#gd#add('rust', function('s:gotodef'))
@ -198,7 +202,9 @@ function! s:language_specified_mappings() abort
\ . string(function('s:execCMD')) . ', ["cargo fmt"])', \ . string(function('s:execCMD')) . ', ["cargo fmt"])',
\ 'format project files', 1) \ 'format project files', 1)
if SpaceVim#layers#lsp#check_filetype('rust') if spacevim#layers#lsp#check_filetype('rust')
\ || spacevim#layers#lsp#check_server('rls')
\ || spacevim#layers#lsp#check_server('rust_analyzer')
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> nnoremap <silent><buffer> gD :<C-u>call SpaceVim#lsp#go_to_typedef()<Cr>