]> Sergey Matveev's repositories - dotfiles.git/commitdiff
Move to vim-lsc from vim-lsp
authorSergey Matveev <stargrave@stargrave.org>
Tue, 11 Jan 2022 13:14:14 +0000 (16:14 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Thu, 27 Jan 2022 11:35:14 +0000 (14:35 +0300)
vim/.vim/ftplugin/c/lsp.vim [deleted file]
vim/.vim/ftplugin/go/lsp.vim [deleted file]
vim/.vim/ftplugin/python/lsp.vim [deleted file]
vim/.vim/pack/stargrave/start/lsp/autoload/mylsp.vim [deleted file]
vim/.vim/pack/stargrave/start/lsp/plugin/lsp.vim [deleted file]
vim/.vim/pack/stargrave/start/py-importcompl/autoload/python/importcompl.vim
vim/.vim/plugin/lsp.vim [new file with mode: 0644]

diff --git a/vim/.vim/ftplugin/c/lsp.vim b/vim/.vim/ftplugin/c/lsp.vim
deleted file mode 100644 (file)
index f033c07..0000000
+++ /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 (file)
index ceaad66..0000000
+++ /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 (file)
index 7cbc696..0000000
+++ /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 (file)
index e64ccc9..0000000
+++ /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 (file)
index c7930b4..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-if exists("*<SID>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 <buffer> [g <Plug>(lsp-previous-diagnostic)
-    nmap <buffer> ]g <Plug>(lsp-next-diagnostic)
-    nmap <buffer> gd <plug>(lsp-definition)
-    nmap <buffer> K <plug>(lsp-hover)
-endfunction
-
-augroup lsp_install
-    autocmd!
-    autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
-augroup END
-
-map <F6> :call mylsp#qfpopulate()<CR>:copen<CR>
index aa9a1685df669c28aac1952af2ebbc3ecf9b64a3..e516ad662bc5ce2794fa247d82e8b8b6407e382d 100644 (file)
@@ -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 (file)
index 0000000..532b5e0
--- /dev/null
@@ -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": "<C-W>gd",
+    \ "ShowHover": v:true,
+    \ "Completion": "omnifunc",
+\ }
+
+map <F6> :LSClientAllDiagnostics<CR>