refactor(nvim): LSP configuration

This commit is contained in:
Oliver Davies 2022-01-29 00:51:26 +00:00
parent 55f899b7ae
commit 49c6254fe1
2 changed files with 41 additions and 12 deletions

View file

@ -5,8 +5,8 @@ end
local nvim_status = require "lsp-status" local nvim_status = require "lsp-status"
local imap = require "opdavies.keymap".imap local imap = require("opdavies.keymap").imap
local nmap = require "opdavies.keymap".nmap local nmap = require("opdavies.keymap").nmap
local buf_nnoremap = function(opts) local buf_nnoremap = function(opts)
opts.buffer = 0 opts.buffer = 0
@ -19,7 +19,7 @@ local buf_inoremap = function(opts)
end end
local updated_capabilities = vim.lsp.protocol.make_client_capabilities() 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) local custom_init = function(client)
client.config.flags = client.config.flags or {} client.config.flags = client.config.flags or {}
@ -34,16 +34,25 @@ local custom_attach = function(client)
-- Keymaps -- Keymaps
buf_inoremap { "<c-s>", vim.lsp.buf.signature_help } buf_inoremap { "<c-s>", vim.lsp.buf.signature_help }
buf_nnoremap { "<space>cr", vim.lsp.buf.rename } buf_nnoremap { "<leader>ca", "<cmd>Telescope lsp_code_actions sorting_strategy=ascending theme=dropdown<cr>" }
-- telescope_mapper("<space>ca", "lsp_code_actions", nil, true) buf_nnoremap { "<leader>dl", "<cmd>Telescope diagnostics<cr>" }
buf_nnoremap { "<leader>dn", vim.diagnostic.goto_next }
buf_nnoremap { "<leader>dp", vim.diagnostic.goto_prev }
buf_nnoremap { "<leader>rn", vim.lsp.buf.rename }
buf_nnoremap { "<leader>rr", "<cmd>LspRestart<cr>" }
buf_nnoremap { "gd", vim.lsp.buf.definition } buf_inoremap { "K", vim.lsp.buf.hover }
buf_nnoremap { "gD", vim.lsp.buf.declaration } buf_nnoremap { "gD", vim.lsp.buf.declaration }
buf_nnoremap { "gT", vim.lsp.buf.type_definition } buf_nnoremap { "gT", vim.lsp.buf.type_definition }
buf_nnoremap { "gd", vim.lsp.buf.definition }
-- buf_nnoremap { "<space>gI", handlers.implementation } -- buf_nnoremap { "<space>gI", handlers.implementation }
buf_nnoremap { "<space>lr", "<cmd>lua R('tj.lsp.codelens').run()<CR>" }
buf_nnoremap { "<space>rr", "LspRestart" } -- telescope_mapper("<leader>ca", "lsp_code_actions", nil, true)
-- telescope_mapper("<leader>wd", "lsp_document_symbols", { ignore_filename = true }, true)
-- telescope_mapper("<leader>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 if filetype ~= "lua" then
buf_nnoremap { "K", vim.lsp.buf.hover } buf_nnoremap { "K", vim.lsp.buf.hover }
@ -59,13 +68,18 @@ local custom_attach = function(client)
augroup END augroup END
]] ]]
end end
-- Attach any filetype specific options to the client
-- filetype_attach[filetype](client)
end end
local servers = { local servers = {
ansiblels = true, ansiblels = true,
bashls = true, bashls = true,
cssls = true, cssls = true,
gopls = true,
html = true, html = true,
-- intelephense = true
tsserver = true, tsserver = true,
vuels = true, vuels = true,
yamlls = true, yamlls = true,
@ -79,14 +93,26 @@ local servers = {
Lua = { Lua = {
diagnostics = { diagnostics = {
globals = { "vim" }, globals = { "vim" },
} },
} },
} },
}, },
tailwindcss = { tailwindcss = {
filetypes = { "html", "html.twig" }, filetypes = { "html", "html.twig" },
} },
-- tsserver = {
-- filetypes = {
-- "javascript",
-- "javascriptreact",
-- "javascript.jsx",
-- "typescript",
-- "typescriptreact",
-- "typescript.tsx",
-- "vue",
-- },
-- },
} }
local setup_server = function(server, config) local setup_server = function(server, config)
@ -113,3 +139,5 @@ end
for server, config in pairs(servers) do for server, config in pairs(servers) do
setup_server(server, config) setup_server(server, config)
end end
require "opdavies.lsp.null-ls"

View file

@ -101,6 +101,7 @@ local function set_vim_o()
end end
vim.opt.clipboard:append "unnamedplus" vim.opt.clipboard:append "unnamedplus"
vim.opt.completeopt = {"menu", "menuone", "noselect"}
end end
M.setup = function() M.setup = function()