From 01fb86734d5d83bfc44978d9ebf0927f5a37944e Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Tue, 11 Jan 2022 16:14:14 +0300 Subject: [PATCH] Move to vim-lsc from vim-lsp --- vim/.vim/ftplugin/c/lsp.vim | 5 ---- vim/.vim/ftplugin/go/lsp.vim | 5 ---- vim/.vim/ftplugin/python/lsp.vim | 14 ---------- .../stargrave/start/lsp/autoload/mylsp.vim | 16 ------------ .../pack/stargrave/start/lsp/plugin/lsp.vim | 22 ---------------- .../autoload/python/importcompl.vim | 9 ++++--- vim/.vim/plugin/lsp.vim | 26 +++++++++++++++++++ 7 files changed, 32 insertions(+), 65 deletions(-) delete mode 100644 vim/.vim/ftplugin/c/lsp.vim delete mode 100644 vim/.vim/ftplugin/go/lsp.vim delete mode 100644 vim/.vim/ftplugin/python/lsp.vim delete mode 100644 vim/.vim/pack/stargrave/start/lsp/autoload/mylsp.vim delete mode 100644 vim/.vim/pack/stargrave/start/lsp/plugin/lsp.vim create mode 100644 vim/.vim/plugin/lsp.vim diff --git a/vim/.vim/ftplugin/c/lsp.vim b/vim/.vim/ftplugin/c/lsp.vim deleted file mode 100644 index f033c07..0000000 --- a/vim/.vim/ftplugin/c/lsp.vim +++ /dev/null @@ -1,5 +0,0 @@ -au User lsp_setup call lsp#register_server({ -\ "name": "clangd", -\ "cmd": ["clangd"], -\ "allowlist": ["c", "cpp", "objc", "objcpp"], -\}) diff --git a/vim/.vim/ftplugin/go/lsp.vim b/vim/.vim/ftplugin/go/lsp.vim deleted file mode 100644 index ceaad66..0000000 --- a/vim/.vim/ftplugin/go/lsp.vim +++ /dev/null @@ -1,5 +0,0 @@ -au User lsp_setup call lsp#register_server({ -\ "name": "gopls", -\ "cmd": ["gopls"], -\ "allowlist": ["go"], -\}) diff --git a/vim/.vim/ftplugin/python/lsp.vim b/vim/.vim/ftplugin/python/lsp.vim deleted file mode 100644 index 7cbc696..0000000 --- a/vim/.vim/ftplugin/python/lsp.vim +++ /dev/null @@ -1,14 +0,0 @@ -if executable("pyls") - " pip install 'python-language-server[all]' - au User lsp_setup call lsp#register_server({ - \ "name": "pyls", - \ "cmd": {server_info->["pyls"]}, - \ "allowlist": ["python"], - \ "workspace_config": {"pyls": { - \ "configurationSources": ["flake8"], - \ "plugins": { - \ "mccabe": {"enabled": v:false}, - \ }, - \ }}, - \}) -endif diff --git a/vim/.vim/pack/stargrave/start/lsp/autoload/mylsp.vim b/vim/.vim/pack/stargrave/start/lsp/autoload/mylsp.vim deleted file mode 100644 index e64ccc9..0000000 --- a/vim/.vim/pack/stargrave/start/lsp/autoload/mylsp.vim +++ /dev/null @@ -1,16 +0,0 @@ -" That function requires vim-lsp/autoload/lsp/ui/vim/diagnostics.vim: -" function! lsp#ui#vim#diagnostics#get_all_buffer_diagnostics(...) abort -" return s:get_all_buffer_diagnostics() -" endfunction - -function! mylsp#qfpopulate() abort - let l = [] - for d in lsp#ui#vim#diagnostics#get_all_buffer_diagnostics() - call add(l, { - \"lnum": d["range"]["start"]["line"], - \"col": d["range"]["start"]["character"], - \"text": d["message"], - \"bufnr": bufnr()}) - endfor - call setqflist(l, "r") -endfunction diff --git a/vim/.vim/pack/stargrave/start/lsp/plugin/lsp.vim b/vim/.vim/pack/stargrave/start/lsp/plugin/lsp.vim deleted file mode 100644 index c7930b4..0000000 --- a/vim/.vim/pack/stargrave/start/lsp/plugin/lsp.vim +++ /dev/null @@ -1,22 +0,0 @@ -if exists("*on_lsp_buffer_enabled") | finish | endif - -let g:lsp_auto_enable = 1 - -let g:lsp_diagnostics_echo_cursor = 1 -let g:lsp_diagnostics_echo_delay = -1 -let g:lsp_signature_help_enabled = 0 - -function! s:on_lsp_buffer_enabled() abort - setlocal omnifunc=lsp#complete - nmap [g (lsp-previous-diagnostic) - nmap ]g (lsp-next-diagnostic) - nmap gd (lsp-definition) - nmap K (lsp-hover) -endfunction - -augroup lsp_install - autocmd! - autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled() -augroup END - -map :call mylsp#qfpopulate():copen diff --git a/vim/.vim/pack/stargrave/start/py-importcompl/autoload/python/importcompl.vim b/vim/.vim/pack/stargrave/start/py-importcompl/autoload/python/importcompl.vim index aa9a168..e516ad6 100644 --- a/vim/.vim/pack/stargrave/start/py-importcompl/autoload/python/importcompl.vim +++ b/vim/.vim/pack/stargrave/start/py-importcompl/autoload/python/importcompl.vim @@ -56,10 +56,13 @@ function! python#importcompl#all() abort let imports[m[2]] = m[1] endfor endfor + + let lines = getloclist(winnr()) + if len(lines) == 0 | let lines = getqflist() | endif let result = [] - for diag in lsp#ui#vim#diagnostics#get_all_buffer_diagnostics() - if diag["message"] !~ "^undefined name" | continue | endif - let m = diag["message"][strridx(diag["message"][:-2], "'")+1:-2] + for line in lines + if line.text !~ "^undefined name" | continue | endif + let m = line.text[strridx(line.text[:-2], "'")+1:-2] if len(m) == 0 || !has_key(imports, m) | continue | endif call insert(result, imports[m]) endfor diff --git a/vim/.vim/plugin/lsp.vim b/vim/.vim/plugin/lsp.vim new file mode 100644 index 0000000..532b5e0 --- /dev/null +++ b/vim/.vim/plugin/lsp.vim @@ -0,0 +1,26 @@ +" go get golang.org/x/tools/gopls@latest +" pip install 'python-language-server[all]' + +let g:lsc_enable_autocomplete = v:false +let g:lsc_server_commands = { + \ "c": {"command": "clangd --log=error"}, + \ "cpp": {"command": "clangd --log=error"}, + \ "go": {"command": "gopls", "log_level": "Error"}, + \ "python": { + \ "command": "pyls", + \ "workspace_config": {"pyls": { + \ "configurationSources": ["flake8"], + \ "plugins": { + \ "mccabe": {"enabled": v:false}, + \ }, + \ }}, + \ }, +\ } +let g:lsc_auto_map = { + \ "GoToDefinition": "gd", + \ "GoToDefinitionSplit": "gd", + \ "ShowHover": v:true, + \ "Completion": "omnifunc", +\ } + +map :LSClientAllDiagnostics -- 2.44.0