minor updates

This commit is contained in:
Andy Teijelo 2022-10-26 16:55:41 -04:00
parent 57ee993ab3
commit 6a174ec543
2 changed files with 65 additions and 64 deletions

View file

@ -24,5 +24,4 @@ require "user.lsp"
require "user.dap" require "user.dap"
require "user.exrc" require "user.exrc"
--require "user.vimspector"
require "user.fidget" require "user.fidget"

View file

@ -2,7 +2,7 @@ local M = {}
local status_cmp_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") local status_cmp_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
if not status_cmp_ok then if not status_cmp_ok then
return return
end end
M.capabilities = vim.lsp.protocol.make_client_capabilities() M.capabilities = vim.lsp.protocol.make_client_capabilities()
@ -10,86 +10,88 @@ M.capabilities.textDocument.completion.completionItem.snippetSupport = true
M.capabilities = cmp_nvim_lsp.update_capabilities(M.capabilities) M.capabilities = cmp_nvim_lsp.update_capabilities(M.capabilities)
M.setup = function() M.setup = function()
local signs = { local signs = {
{ name = "DiagnosticSignError", text = "" }, { name = "DiagnosticSignError", text = "" },
{ name = "DiagnosticSignWarn", text = "" }, { name = "DiagnosticSignWarn", text = "" },
{ name = "DiagnosticSignHint", text = "" }, { name = "DiagnosticSignHint", text = "" },
{ name = "DiagnosticSignInfo", text = "" }, { name = "DiagnosticSignInfo", text = "" },
} }
for _, sign in ipairs(signs) do for _, sign in ipairs(signs) do
vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" }) vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" })
end end
local config = { local config = {
virtual_text = true, -- disable virtual text virtual_text = true, -- disable virtual text
signs = { signs = {
active = signs, -- show signs active = signs, -- show signs
}, },
update_in_insert = true, update_in_insert = true,
underline = true, underline = true,
severity_sort = true, severity_sort = true,
float = { float = {
focusable = true, focusable = true,
style = "minimal", style = "minimal",
border = "rounded", border = "rounded",
source = "always", source = "always",
header = "", header = "",
prefix = "", prefix = "",
}, },
} }
vim.diagnostic.config(config) vim.diagnostic.config(config)
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
border = "rounded", border = "rounded",
}) })
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
border = "rounded", border = "rounded",
}) })
end end
local function lsp_keymaps(bufnr) local function lsp_keymaps(bufnr)
local opts = { noremap = true, silent = true } local opts = { noremap = true, silent = true }
local keymap = vim.api.nvim_buf_set_keymap local keymap = vim.api.nvim_buf_set_keymap
keymap(bufnr, "n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts) keymap(bufnr, "n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
keymap(bufnr, "n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts) keymap(bufnr, "n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts) keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
keymap(bufnr, "n", "gI", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts) keymap(bufnr, "n", "gI", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts) keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
keymap(bufnr, "n", "gl", "<cmd>lua vim.diagnostic.open_float()<CR>", opts) keymap(bufnr, "n", "gl", "<cmd>lua vim.diagnostic.open_float()<CR>", opts)
keymap(bufnr, "n", "<leader>lf", "<cmd>lua vim.lsp.buf.format{ async = true }<cr>", opts) keymap(bufnr, "n", "<leader>lf", "<cmd>lua vim.lsp.buf.format{ async = true }<cr>", opts)
keymap(bufnr, "v", "<leader>lf", "<esc><cmd>'<,'>lua vim.lsp.buf.format()<cr>", opts) keymap(bufnr, "v", "<leader>lf", "<esc><cmd>'<,'>lua vim.lsp.buf.format()<cr>", opts)
keymap(bufnr, "x", "<leader>lf", "<esc><cmd>'<,'>lua vim.lsp.buf.format()<cr>", opts) keymap(bufnr, "x", "<leader>lf", "<esc><cmd>'<,'>lua vim.lsp.buf.format()<cr>", opts)
keymap(bufnr, "n", "<leader>li", "<cmd>LspInfo<cr>", opts) keymap(bufnr, "n", "<leader>li", "<cmd>LspInfo<cr>", opts)
keymap(bufnr, "n", "<leader>lI", "<cmd>LspInstallInfo<cr>", opts) keymap(bufnr, "n", "<leader>lI", "<cmd>LspInstallInfo<cr>", opts)
keymap(bufnr, "n", "<leader>la", "<cmd>lua vim.lsp.buf.code_action()<cr>", opts) keymap(bufnr, "n", "<leader>la", "<cmd>lua vim.lsp.buf.code_action()<cr>", opts)
keymap(bufnr, "n", "<leader>lj", "<cmd>lua vim.diagnostic.goto_next({buffer=0})<cr>", opts) keymap(bufnr, "n", "<leader>lj", "<cmd>lua vim.diagnostic.goto_next({buffer=0})<cr>", opts)
keymap(bufnr, "n", "<leader>lk", "<cmd>lua vim.diagnostic.goto_prev({buffer=0})<cr>", opts) keymap(bufnr, "n", "<leader>lk", "<cmd>lua vim.diagnostic.goto_prev({buffer=0})<cr>", opts)
keymap(bufnr, "n", "<leader>lr", "<cmd>lua vim.lsp.buf.rename()<cr>", opts) keymap(bufnr, "n", "<leader>lr", "<cmd>lua vim.lsp.buf.rename()<cr>", opts)
keymap(bufnr, "n", "<leader>ls", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts) keymap(bufnr, "n", "<leader>ls", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
keymap(bufnr, "n", "<leader>lq", "<cmd>lua vim.diagnostic.setloclist()<CR>", opts) keymap(bufnr, "n", "<leader>lq", "<cmd>lua vim.diagnostic.setloclist()<CR>", opts)
keymap(bufnr, "v", "<leader>lf", "<esc><cmd>'<,'>lua vim.lsp.buf.format{ async = true }<cr>", opts)
keymap(bufnr, "x", "<leader>lf", "<esc><cmd>'<,'>lua vim.lsp.buf.format{ async = true }<cr>", opts)
end end
M.on_attach = function(client, bufnr) M.on_attach = function(client, bufnr)
if client.name == "tsserver" then if client.name == "tsserver" then
client.server_capabilities.documentFormattingProvider = false client.server_capabilities.documentFormattingProvider = false
end end
if client.name == "sumneko_lua" then if client.name == "sumneko_lua" then
client.server_capabilities.documentFormattingProvider = false client.server_capabilities.documentFormattingProvider = false
end end
lsp_keymaps(bufnr) lsp_keymaps(bufnr)
local status_ok, illuminate = pcall(require, "illuminate") local status_ok, illuminate = pcall(require, "illuminate")
if not status_ok then if not status_ok then
return return
end end
illuminate.on_attach(client) illuminate.on_attach(client)
end end
return M return M