From 49c6254fe11ea72efbdc14a72e13330309655774 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sat, 29 Jan 2022 00:51:26 +0000 Subject: [PATCH] refactor(nvim): LSP configuration --- roles/neovim/files/lua/opdavies/lsp/init.lua | 52 +++++++++++++++----- roles/neovim/files/lua/opdavies/options.lua | 1 + 2 files changed, 41 insertions(+), 12 deletions(-) diff --git a/roles/neovim/files/lua/opdavies/lsp/init.lua b/roles/neovim/files/lua/opdavies/lsp/init.lua index c08b3a3..e18d832 100644 --- a/roles/neovim/files/lua/opdavies/lsp/init.lua +++ b/roles/neovim/files/lua/opdavies/lsp/init.lua @@ -5,8 +5,8 @@ end local nvim_status = require "lsp-status" -local imap = require "opdavies.keymap".imap -local nmap = require "opdavies.keymap".nmap +local imap = require("opdavies.keymap").imap +local nmap = require("opdavies.keymap").nmap local buf_nnoremap = function(opts) opts.buffer = 0 @@ -19,7 +19,7 @@ local buf_inoremap = function(opts) end local updated_capabilities = vim.lsp.protocol.make_client_capabilities() -updated_capabilities = require('cmp_nvim_lsp').update_capabilities(updated_capabilities) +updated_capabilities = require("cmp_nvim_lsp").update_capabilities(updated_capabilities) local custom_init = function(client) client.config.flags = client.config.flags or {} @@ -34,16 +34,25 @@ local custom_attach = function(client) -- Keymaps buf_inoremap { "", vim.lsp.buf.signature_help } - buf_nnoremap { "cr", vim.lsp.buf.rename } - -- telescope_mapper("ca", "lsp_code_actions", nil, true) + buf_nnoremap { "ca", "Telescope lsp_code_actions sorting_strategy=ascending theme=dropdown" } + buf_nnoremap { "dl", "Telescope diagnostics" } + buf_nnoremap { "dn", vim.diagnostic.goto_next } + buf_nnoremap { "dp", vim.diagnostic.goto_prev } + buf_nnoremap { "rn", vim.lsp.buf.rename } + buf_nnoremap { "rr", "LspRestart" } - buf_nnoremap { "gd", vim.lsp.buf.definition } + buf_inoremap { "K", vim.lsp.buf.hover } buf_nnoremap { "gD", vim.lsp.buf.declaration } buf_nnoremap { "gT", vim.lsp.buf.type_definition } + buf_nnoremap { "gd", vim.lsp.buf.definition } -- buf_nnoremap { "gI", handlers.implementation } - buf_nnoremap { "lr", "lua R('tj.lsp.codelens').run()" } - buf_nnoremap { "rr", "LspRestart" } + + -- telescope_mapper("ca", "lsp_code_actions", nil, true) + -- telescope_mapper("wd", "lsp_document_symbols", { ignore_filename = true }, true) + -- telescope_mapper("ww", "lsp_dynamic_workspace_symbols", { ignore_filename = true }, true) + -- telescope_mapper("gI", "lsp_implementations", nil, true) + -- telescope_mapper("gr", "lsp_references", nil, true) if filetype ~= "lua" then buf_nnoremap { "K", vim.lsp.buf.hover } @@ -59,13 +68,18 @@ local custom_attach = function(client) augroup END ]] end + + -- Attach any filetype specific options to the client + -- filetype_attach[filetype](client) end local servers = { ansiblels = true, bashls = true, cssls = true, + gopls = true, html = true, + -- intelephense = true tsserver = true, vuels = true, yamlls = true, @@ -79,14 +93,26 @@ local servers = { Lua = { diagnostics = { globals = { "vim" }, - } - } - } + }, + }, + }, }, tailwindcss = { filetypes = { "html", "html.twig" }, - } + }, + + -- tsserver = { + -- filetypes = { + -- "javascript", + -- "javascriptreact", + -- "javascript.jsx", + -- "typescript", + -- "typescriptreact", + -- "typescript.tsx", + -- "vue", + -- }, + -- }, } local setup_server = function(server, config) @@ -113,3 +139,5 @@ end for server, config in pairs(servers) do setup_server(server, config) end + +require "opdavies.lsp.null-ls" diff --git a/roles/neovim/files/lua/opdavies/options.lua b/roles/neovim/files/lua/opdavies/options.lua index 6101f1d..f1c628e 100644 --- a/roles/neovim/files/lua/opdavies/options.lua +++ b/roles/neovim/files/lua/opdavies/options.lua @@ -101,6 +101,7 @@ local function set_vim_o() end vim.opt.clipboard:append "unnamedplus" + vim.opt.completeopt = {"menu", "menuone", "noselect"} end M.setup = function()