diff options
Diffstat (limited to '.config/nvim/lua/_lsp')
-rw-r--r-- | .config/nvim/lua/_lsp/bash-ls.lua | 2 | ||||
-rw-r--r-- | .config/nvim/lua/_lsp/docker-ls.lua | 2 | ||||
-rw-r--r-- | .config/nvim/lua/_lsp/general.lua | 15 | ||||
-rw-r--r-- | .config/nvim/lua/_lsp/init.lua | 59 | ||||
-rw-r--r-- | .config/nvim/lua/_lsp/json-ls.lua | 1 | ||||
-rw-r--r-- | .config/nvim/lua/_lsp/lua-ls.lua | 20 | ||||
-rw-r--r-- | .config/nvim/lua/_lsp/python-ls.lua | 4 | ||||
-rw-r--r-- | .config/nvim/lua/_lsp/vim-ls.lua | 2 | ||||
-rw-r--r-- | .config/nvim/lua/_lsp/vim.lua | 2 | ||||
-rw-r--r-- | .config/nvim/lua/_lsp/wrapper.lua | 129 | ||||
-rw-r--r-- | .config/nvim/lua/_lsp/yaml-ls.lua | 4 |
11 files changed, 79 insertions, 161 deletions
diff --git a/.config/nvim/lua/_lsp/bash-ls.lua b/.config/nvim/lua/_lsp/bash-ls.lua index 8be0383..7a12dc0 100644 --- a/.config/nvim/lua/_lsp/bash-ls.lua +++ b/.config/nvim/lua/_lsp/bash-ls.lua @@ -1,2 +1,2 @@ -- npm i -g bash-language-server -require'lspconfig'.bashls.setup{} +require'lspconfig'.bashls.setup {on_attach = require'_lsp'.common_on_attach} diff --git a/.config/nvim/lua/_lsp/docker-ls.lua b/.config/nvim/lua/_lsp/docker-ls.lua index ad6e220..878aa86 100644 --- a/.config/nvim/lua/_lsp/docker-ls.lua +++ b/.config/nvim/lua/_lsp/docker-ls.lua @@ -1,2 +1,2 @@ -- npm install -g dockerfile-language-server-nodejs -require'lspconfig'.dockerls.setup{} +require'lspconfig'.dockerls.setup {on_attach = require'_lsp'.common_on_attach} diff --git a/.config/nvim/lua/_lsp/general.lua b/.config/nvim/lua/_lsp/general.lua deleted file mode 100644 index fa28dbc..0000000 --- a/.config/nvim/lua/_lsp/general.lua +++ /dev/null @@ -1,15 +0,0 @@ -require"lspconfig".efm.setup { - init_options = {documentFormatting = true}, - filetypes = {"lua"}, - settings = { - rootMarkers = {".git/"}, - languages = { - lua = { - { - formatCommand = "lua-format -i --no-keep-simple-function-one-line --no-break-after-operator --column-limit=150 --break-after-table-lb", - formatStdin = true - } - } - } - } -} diff --git a/.config/nvim/lua/_lsp/init.lua b/.config/nvim/lua/_lsp/init.lua index 4515e7c..12ce36a 100644 --- a/.config/nvim/lua/_lsp/init.lua +++ b/.config/nvim/lua/_lsp/init.lua @@ -1,8 +1,24 @@ ---TODO figure out why this don't work -vim.fn.sign_define("LspDiagnosticsSignError", {texthl = "LspDiagnosticsSignError", text = "", numhl = "LspDiagnosticsSignError"}) -vim.fn.sign_define("LspDiagnosticsSignWarning", {texthl = "LspDiagnosticsSignWarning", text = "", numhl = "LspDiagnosticsSignWarning"}) -vim.fn.sign_define("LspDiagnosticsSignInformation", {texthl = "LspDiagnosticsSignInformation", text = "", numhl = "LspDiagnosticsSignInformation"}) -vim.fn.sign_define("LspDiagnosticsSignHint", {texthl = "LspDiagnosticsSignHint", text = "", numhl = "LspDiagnosticsSignHint"}) +-- TODO figure out why this don't work +vim.fn.sign_define("LspDiagnosticsSignError", { + texthl = "LspDiagnosticsSignError", + text = "", + numhl = "LspDiagnosticsSignError" +}) +vim.fn.sign_define("LspDiagnosticsSignWarning", { + texthl = "LspDiagnosticsSignWarning", + text = "", + numhl = "LspDiagnosticsSignWarning" +}) +vim.fn.sign_define("LspDiagnosticsSignInformation", { + texthl = "LspDiagnosticsSignInformation", + text = "", + numhl = "LspDiagnosticsSignInformation" +}) +vim.fn.sign_define("LspDiagnosticsSignHint", { + texthl = "LspDiagnosticsSignHint", + text = "", + numhl = "LspDiagnosticsSignHint" +}) vim.cmd('nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>') vim.cmd('nnoremap <silent> gD <cmd>lua vim.lsp.buf.declaration()<CR>') @@ -17,3 +33,36 @@ vim.cmd('nnoremap <silent> <C-n> :Lspsaga diagnostic_jump_next<CR>') vim.cmd('nnoremap <silent> <C-f> <cmd>lua require(\'lspsaga.action\').smart_scroll_with_saga(1)<CR>') -- scroll up hover doc vim.cmd('nnoremap <silent> <C-b> <cmd>lua require(\'lspsaga.action\').smart_scroll_with_saga(-1)<CR>') +vim.cmd('command! -nargs=0 LspVirtualTextToggle lua require("lsp/virtual_text").toggle()') + +--[[ " autoformat +autocmd BufWritePre *.js lua vim.lsp.buf.formatting_sync(nil, 100) +autocmd BufWritePre *.jsx lua vim.lsp.buf.formatting_sync(nil, 100) +autocmd BufWritePre *.lua lua vim.lsp.buf.formatting_sync(nil, 100) ]] +-- Java +-- autocmd FileType java nnoremap ca <Cmd>lua require('jdtls').code_action()<CR> + +local lsp_config = {} + +function lsp_config.common_on_attach(client, bufnr) + + -- Set autocommands conditional on server_capabilities + if client.resolved_capabilities.document_highlight then + vim.api.nvim_exec([[ + hi LspReferenceRead cterm=bold ctermbg=red guibg=#464646 + hi LspReferenceText cterm=bold ctermbg=red guibg=#464646 + hi LspReferenceWrite cterm=bold ctermbg=red guibg=#464646 + augroup lsp_document_highlight + autocmd! * <buffer> + autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight() + autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references() + augroup END + ]], false) + end +end + +-- Use a loop to conveniently both setup defined servers +-- and map buffer local keybindings when the language server attaches +-- local servers = {"pyright", "tsserver"} +-- for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup {on_attach = on_attach} end +return lsp_config diff --git a/.config/nvim/lua/_lsp/json-ls.lua b/.config/nvim/lua/_lsp/json-ls.lua index d13fed3..4fbbeff 100644 --- a/.config/nvim/lua/_lsp/json-ls.lua +++ b/.config/nvim/lua/_lsp/json-ls.lua @@ -1,5 +1,6 @@ -- npm install -g vscode-json-languageserver require'lspconfig'.jsonls.setup { + on_attach = require'_lsp'.common_on_attach, commands = { Format = { function() diff --git a/.config/nvim/lua/_lsp/lua-ls.lua b/.config/nvim/lua/_lsp/lua-ls.lua index c04219a..5768e5d 100644 --- a/.config/nvim/lua/_lsp/lua-ls.lua +++ b/.config/nvim/lua/_lsp/lua-ls.lua @@ -1,21 +1,26 @@ --- https://github.com/sumneko/lua-language-server/wiki/Build-and-Run-(Standalone) + -- https://github.com/sumneko/lua-language-server/wiki/Build-and-Run-(Standalone) USER = vim.fn.expand('$USER') local sumneko_root_path = "" local sumneko_binary = "" if vim.fn.has("mac") == 1 then - sumneko_root_path = "/Users/" .. USER .. "/.config/nvim/lua-language-server" - sumneko_binary = "/Users/" .. USER .. "/.config/nvim/lua-language-server/bin/macOS/lua-language-server" + sumneko_root_path = "/Users/" .. USER .. + "/.config/nvim/ls/lua-language-server" + sumneko_binary = "/Users/" .. USER .. + "/.config/nvim/ls/lua-language-server/bin/macOS/lua-language-server" elseif vim.fn.has("unix") == 1 then - sumneko_root_path = "/home/" .. USER .. "/.config/nvim/lua-language-server" - sumneko_binary = "/home/" .. USER .. "/.config/nvim/lua-language-server/bin/Linux/lua-language-server" + sumneko_root_path = "/home/" .. USER .. + "/.config/nvim/ls/lua-language-server" + sumneko_binary = "/home/" .. USER .. + "/.config/nvim/ls/lua-language-server/bin/Linux/lua-language-server" else print("Unsupported system for sumneko") end require'lspconfig'.sumneko_lua.setup { cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"}, + on_attach = require'_lsp'.common_on_attach, settings = { Lua = { runtime = { @@ -30,7 +35,10 @@ require'lspconfig'.sumneko_lua.setup { }, workspace = { -- Make the server aware of Neovim runtime files - library = {[vim.fn.expand('$VIMRUNTIME/lua')] = true, [vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true} + library = { + [vim.fn.expand('$VIMRUNTIME/lua')] = true, + [vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true + } } } } diff --git a/.config/nvim/lua/_lsp/python-ls.lua b/.config/nvim/lua/_lsp/python-ls.lua index 11eeef9..d07f59b 100644 --- a/.config/nvim/lua/_lsp/python-ls.lua +++ b/.config/nvim/lua/_lsp/python-ls.lua @@ -1,2 +1,4 @@ -- npm i -g pyright -require'lspconfig'.pyright.setup{} +require'lspconfig'.pyright.setup{ + on_attach = require'_lsp'.common_on_attach, +} diff --git a/.config/nvim/lua/_lsp/vim-ls.lua b/.config/nvim/lua/_lsp/vim-ls.lua new file mode 100644 index 0000000..08039a3 --- /dev/null +++ b/.config/nvim/lua/_lsp/vim-ls.lua @@ -0,0 +1,2 @@ +-- npm install -g vim-language-server +require'lspconfig'.vimls.setup {on_attach = require'_lsp'.common_on_attach} diff --git a/.config/nvim/lua/_lsp/vim.lua b/.config/nvim/lua/_lsp/vim.lua deleted file mode 100644 index a7555c6..0000000 --- a/.config/nvim/lua/_lsp/vim.lua +++ /dev/null @@ -1,2 +0,0 @@ --- npm install -g vim-language-server -require'lspconfig'.vimls.setup{} diff --git a/.config/nvim/lua/_lsp/wrapper.lua b/.config/nvim/lua/_lsp/wrapper.lua deleted file mode 100644 index 7f3647c..0000000 --- a/.config/nvim/lua/_lsp/wrapper.lua +++ /dev/null @@ -1,129 +0,0 @@ -local lsp_wrapper = {} - --- buf - -function lsp_wrapper.add_to_workspace_folder() - vim.lsp.buf.add_workspace_folder() -end - -function lsp_wrapper.clear_references() - vim.lsp.buf.clear_references() -end - -function lsp_wrapper.code_action() - vim.lsp.buf.code_action() -end - -function lsp_wrapper.declaration() - vim.lsp.buf.declaration() - vim.lsp.buf.clear_references() -end - -function lsp_wrapper.definition() - vim.lsp.buf.definition() - vim.lsp.buf.clear_references() -end - -function lsp_wrapper.document_highlight() - vim.lsp.buf.document_highlight() -end - -function lsp_wrapper.document_symbol() - vim.lsp.buf.document_symbol() -end - -function lsp_wrapper.formatting() - vim.lsp.buf.formatting() -end - -function lsp_wrapper.formatting_sync() - vim.lsp.buf.formatting_sync() -end - -function lsp_wrapper.hover() - vim.lsp.buf.hover() -end - -function lsp_wrapper.implementation() - vim.lsp.buf.implementation() -end - -function lsp_wrapper.incoming_calls() - vim.lsp.buf.incoming_calls() -end - -function lsp_wrapper.list_workspace_folders() - vim.lsp.buf.list_workspace_folders() -end - -function lsp_wrapper.outgoing_calls() - vim.lsp.buf.outgoing_calls() -end - -function lsp_wrapper.range_code_action() - vim.lsp.buf.range_code_action() -end - -function lsp_wrapper.range_formatting() - vim.lsp.buf.range_formatting() -end - -function lsp_wrapper.references() - vim.lsp.buf.references() - vim.lsp.buf.clear_references() -end - -function lsp_wrapper.remove_workspace_folder() - vim.lsp.buf.remove_workspace_folder() -end - -function lsp_wrapper.rename() - vim.lsp.buf.rename() -end - -function lsp_wrapper.signature_help() - vim.lsp.buf.signature_help() -end - -function lsp_wrapper.type_definition() - vim.lsp.buf.type_definition() -end - -function lsp_wrapper.workspace_symbol() - vim.lsp.buf.workspace_symbol() -end - --- diagnostic - -function lsp_wrapper.get_all() - vim.lsp.diagnostic.get_all() -end - -function lsp_wrapper.get_next() - vim.lsp.diagnostic.get_next() -end - -function lsp_wrapper.get_prev() - vim.lsp.diagnostic.get_prev() -end - -function lsp_wrapper.goto_next() - vim.lsp.diagnostic.goto_next() -end - -function lsp_wrapper.goto_prev() - vim.lsp.diagnostic.goto_prev() -end - -function lsp_wrapper.show_line_diagnostics() - vim.lsp.diagnostic.show_line_diagnostics() -end - --- misc - --- :lua print(vim.inspect(vim.lsp.buf_get_clients())) - --- autoformat --- autocmd BufWritePre *.rs lua vim.lsp.buf.formatting_sync(nil, 1000) - -return lsp_wrapper diff --git a/.config/nvim/lua/_lsp/yaml-ls.lua b/.config/nvim/lua/_lsp/yaml-ls.lua index 904f20e..e611572 100644 --- a/.config/nvim/lua/_lsp/yaml-ls.lua +++ b/.config/nvim/lua/_lsp/yaml-ls.lua @@ -1,2 +1,4 @@ -- npm install -g yaml-language-server -require'lspconfig'.yamlls.setup{} +require'lspconfig'.yamlls.setup{ + -- on_attach = require'lsp'.common_on_attach, +} |