1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-03-13 18:25:42 +08:00

fix(lsp): fix lsp support in nvim

Use LanguageClient-neovim for old neovim
This commit is contained in:
Shidong Wang 2021-10-05 23:17:41 +08:00
parent 55365f64f8
commit c32aa6f225
No known key found for this signature in database
GPG Key ID: 41BB7053E835C848
5 changed files with 48 additions and 8 deletions

View File

@ -86,12 +86,12 @@ function! SpaceVim#layers#lsp#plugins() abort
endif
elseif SpaceVim#layers#isLoaded('autocomplete') && get(g:, 'spacevim_autocomplete_method') ==# 'coc'
" nop
elseif has('nvim-0.4.3')
" use neovim build-in lsp
elseif has('nvim')
elseif has('nvim-0.4.3') && $ENABLE_NVIM043LSP
call add(plugins, ['bfredl/nvim-lspmirror', {'merged' : 0}])
call add(plugins, ['bfredl/nvim-lspext', {'merged' : 0}])
call add(plugins, ['shougo/deoplete-lsp', {'merged' : 0}])
elseif has('nvim')
call add(plugins, ['autozimu/LanguageClient-neovim',
\ { 'merged': 0, 'if': has('python3'), 'build' : 'bash install.sh' }])
else
call add(plugins, ['prabirshrestha/async.vim', {'merged' : 0}])
call add(plugins, ['prabirshrestha/vim-lsp', {'merged' : 0}])

View File

@ -6,7 +6,7 @@
" License: GPLv3
"=============================================================================
if $SPACEVIM_LUA && has('nvim')
if $SPACEVIM_LUA && has('nvim-0.5.0')
function! SpaceVim#logger#info(msg) abort
lua require("spacevim.logger").info(
\ require("spacevim").eval("a:msg")

View File

@ -151,7 +151,7 @@ elseif SpaceVim#layers#isLoaded('autocomplete') && get(g:, 'spacevim_autocomplet
function! SpaceVim#lsp#references() abort
call CocAction('jumpReferences')
endfunction
elseif has('nvim-0.4.3')
elseif has('nvim-0.4.3') && $ENABLE_NVIM043LSP
function! SpaceVim#lsp#show_doc() abort
lua require('lsp.plugin')
\ .client.request('textDocument/hover',
@ -191,6 +191,46 @@ elseif has('nvim-0.4.3')
" @todo languageclient do not support refactor
endfunction
elseif has('nvim')
" use LanguageClient-neovim
function! SpaceVim#lsp#reg_server(ft, cmds) abort
let g:LanguageClient_serverCommands[a:ft] = copy(a:cmds)
endfunction
function! SpaceVim#lsp#show_doc() abort
call LanguageClient_textDocument_hover()
endfunction
function! SpaceVim#lsp#go_to_def() abort
call LanguageClient_textDocument_definition()
endfunction
function! SpaceVim#lsp#go_to_typedef() abort
call LanguageClient_textDocument_typeDefinition()
endfunction
function! SpaceVim#lsp#go_to_impl() abort
call LanguageClient_textDocument_implementation()
endfunction
function! SpaceVim#lsp#rename() abort
call LanguageClient_textDocument_rename()
endfunction
function! SpaceVim#lsp#references() abort
call LanguageClient_textDocument_references()
endfunction
function! SpaceVim#lsp#go_to_declaration() abort
call LanguageClient_textDocument_declaration()
endfunction
function! SpaceVim#lsp#documentSymbol()
call LanguageClient_textDocument_documentSymbol()
endfunction
function! SpaceVim#lsp#refactor() abort
" @todo languageclient do not support refactor
endfunction
else
" use vim-lsp
function! SpaceVim#lsp#reg_server(ft, cmds) abort

View File

@ -11,7 +11,7 @@ set cpo&vim
scriptencoding utf-8
if $SPACEVIM_LUA && has('nvim')
if $SPACEVIM_LUA && has('nvim-0.5.0')
function! SpaceVim#plugins#a#alt(request_parse, ...) abort
lua require("spacevim.plugin.a").alt(
\ require("spacevim").eval("a:request_parse"),

View File

@ -8,7 +8,7 @@
if $SPACEVIM_LUA && has('nvim')
if $SPACEVIM_LUA && has('nvim-0.5.0')
function! SpaceVim#plugins#projectmanager#complete_project(ArgLead, CmdLine, CursorPos) abort
return luaeval('require("spacevim.plugin.projectmanager").complete('
\ .'require("spacevim").eval("a:ArgLead"),'