From 7d1e8075b8f156f3f8c300326abf730a1a8f2875 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Mon, 31 May 2021 22:20:30 +0200 Subject: Copying of Luke's dots --- .config/nvim/lua/lsp/efm-general-ls.lua | 4 +++- .config/nvim/lua/lsp/go-ls.lua | 7 +++++++ .config/nvim/lua/lsp/init.lua | 31 +++++++++++++++++++++++-------- .config/nvim/lua/lsp/python-ls.lua | 11 ++++++++++- 4 files changed, 43 insertions(+), 10 deletions(-) create mode 100644 .config/nvim/lua/lsp/go-ls.lua (limited to '.config/nvim/lua/lsp') diff --git a/.config/nvim/lua/lsp/efm-general-ls.lua b/.config/nvim/lua/lsp/efm-general-ls.lua index 16f3037..01bc3ee 100644 --- a/.config/nvim/lua/lsp/efm-general-ls.lua +++ b/.config/nvim/lua/lsp/efm-general-ls.lua @@ -92,7 +92,7 @@ require"lspconfig".efm.setup { -- init_options = {initializationOptions}, cmd = {DATA_PATH .. "/lspinstall/efm/efm-langserver"}, init_options = {documentFormatting = true, codeAction = false}, - filetypes = {"lua", "python", "javascriptreact", "javascript", "sh", "html", "css", "json", "yaml", "markdown"}, + filetypes = {"lua", "python", "javascriptreact", "javascript", "typescript","typescriptreact","sh", "html", "css", "json", "yaml", "markdown", "vue"}, settings = { rootMarkers = {".git/"}, languages = { @@ -101,6 +101,8 @@ require"lspconfig".efm.setup { sh = sh_arguments, javascript = tsserver_args, javascriptreact = tsserver_args, + typescript = tsserver_args, + typescriptreact = tsserver_args, html = {prettier}, css = {prettier}, json = {prettier}, diff --git a/.config/nvim/lua/lsp/go-ls.lua b/.config/nvim/lua/lsp/go-ls.lua new file mode 100644 index 0000000..1311247 --- /dev/null +++ b/.config/nvim/lua/lsp/go-ls.lua @@ -0,0 +1,7 @@ +require'lspconfig'.gopls.setup{ + cmd = {DATA_PATH .. "/lspinstall/go/gopls"}, + settings = {gopls = {analyses = {unusedparams = true}, staticcheck = true}}, + root_dir = require'lspconfig'.util.root_pattern(".git","go.mod","."), + init_options = {usePlaceholders = true, completeUnimported = true}, + on_attach = require'lsp'.common_on_attach +} diff --git a/.config/nvim/lua/lsp/init.lua b/.config/nvim/lua/lsp/init.lua index b07858b..ef2e2f9 100644 --- a/.config/nvim/lua/lsp/init.lua +++ b/.config/nvim/lua/lsp/init.lua @@ -1,19 +1,19 @@ -- TODO figure out why this don't work vim.fn.sign_define( "LspDiagnosticsSignError", - {texthl = "LspDiagnosticsSignError", text = "", numhl = "LspDiagnosticsSignError"} + {texthl = "LspDiagnosticsSignError", text = "", numhl = "LspDiagnosticsSignError"} ) vim.fn.sign_define( "LspDiagnosticsSignWarning", - {texthl = "LspDiagnosticsSignWarning", text = "", numhl = "LspDiagnosticsSignWarning"} + {texthl = "LspDiagnosticsSignWarning", text = "", numhl = "LspDiagnosticsSignWarning"} ) vim.fn.sign_define( "LspDiagnosticsSignHint", - {texthl = "LspDiagnosticsSignHint", text = "", numhl = "LspDiagnosticsSignHint"} + {texthl = "LspDiagnosticsSignHint", text = "", numhl = "LspDiagnosticsSignHint"} ) vim.fn.sign_define( "LspDiagnosticsSignInformation", - {texthl = "LspDiagnosticsSignInformation", text = "", numhl = "LspDiagnosticsSignInformation"} + {texthl = "LspDiagnosticsSignInformation", text = "", numhl = "LspDiagnosticsSignInformation"} ) vim.cmd("nnoremap gd lua vim.lsp.buf.definition()") @@ -21,7 +21,7 @@ vim.cmd("nnoremap gD lua vim.lsp.buf.declaration()") vim.cmd("nnoremap gr lua vim.lsp.buf.references()") vim.cmd("nnoremap gi lua vim.lsp.buf.implementation()") vim.cmd("nnoremap ca :Lspsaga code_action") -vim.cmd("nnoremap K :Lspsaga hoer_doc") +vim.cmd("nnoremap K :Lspsaga hover_doc") -- vim.cmd('nnoremap lua vim.lsp.buf.signature_help()') vim.cmd("nnoremap :Lspsaga diagnostic_jump_prev") vim.cmd("nnoremap :Lspsaga diagnostic_jump_next") @@ -31,6 +31,19 @@ vim.cmd("nnoremap lua require('lspsaga.action').smart_scroll vim.cmd("nnoremap lua require('lspsaga.action').smart_scroll_with_saga(-1)") vim.cmd('command! -nargs=0 LspVirtualTextToggle lua require("lsp/virtual_text").toggle()') +-- Set Default Prefix. +-- Note: You can set a prefix per lsp server in the lv-globals.lua file +vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( + vim.lsp.diagnostic.on_publish_diagnostics, { + virtual_text = { + prefix = "", + spacing = 0, + }, + signs = true, + underline = true, + } +) + -- symbols for autocomplete vim.lsp.protocol.CompletionItemKind = { "  (Text) ", @@ -47,7 +60,7 @@ vim.lsp.protocol.CompletionItemKind = { "  (Value)", " 練 (Enum)", "  (Keyword)", - " ﬌ (Snippet)", + "  (Snippet)", "  (Color)", "  (File)", "  (Reference)", @@ -87,8 +100,10 @@ local function documentHighlight(client, bufnr) end local lsp_config = {} -function lsp_config.common_on_attach(client, bufnr) - documentHighlight(client, bufnr) +if O.document_highlight then + function lsp_config.common_on_attach(client, bufnr) + documentHighlight(client, bufnr) + end end function lsp_config.tsserver_on_attach(client, bufnr) diff --git a/.config/nvim/lua/lsp/python-ls.lua b/.config/nvim/lua/lsp/python-ls.lua index 8cc8b22..d4dfac5 100644 --- a/.config/nvim/lua/lsp/python-ls.lua +++ b/.config/nvim/lua/lsp/python-ls.lua @@ -1,3 +1,4 @@ + -- npm i -g pyright require'lspconfig'.pyright.setup { cmd = {DATA_PATH .. "/lspinstall/python/node_modules/.bin/pyright-langserver", "--stdio"}, @@ -8,7 +9,15 @@ require'lspconfig'.pyright.setup { signs = O.python.diagnostics.signs, underline = O.python.diagnostics.underline, update_in_insert = true - }) + }, + settings = { + python = { + analysis = { + typeCheckingMode = O.python.analysis.type_checking, + autoSearchPaths = O.python.analysis.auto_search_paths, + useLibraryCodeForTypes = O.python.analysis.use_library_code_types + } + } } } -- cgit v1.2.3-70-g09d2