mirror of
https://github.com/marianozunino/nvim.git
synced 2025-06-28 02:23:50 -03:00
dev: automated commit - 2025-05-28 14:17:15
This commit is contained in:
parent
cc9b3f716e
commit
a2d2fcb86e
9 changed files with 69 additions and 93 deletions
|
@ -1,4 +1,3 @@
|
||||||
-- With 2-space indentation
|
|
||||||
return {
|
return {
|
||||||
settings = {
|
settings = {
|
||||||
Lua = {
|
Lua = {
|
|
@ -1,76 +1,60 @@
|
||||||
local M = {
|
local M = {
|
||||||
"neovim/nvim-lspconfig",
|
"mson-org/mason-lspconfig.nvim",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"saghen/blink.cmp",
|
"mson-org/mason.nvim",
|
||||||
"williamboman/mason.nvim",
|
|
||||||
"williamboman/mason-lspconfig.nvim",
|
|
||||||
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
||||||
|
"j-hui/fidget.nvim",
|
||||||
{ "j-hui/fidget.nvim", opts = {} },
|
|
||||||
"ibhagwan/fzf-lua",
|
"ibhagwan/fzf-lua",
|
||||||
|
|
||||||
require("plugins.lsp.extras.lazydev"),
|
require("plugins.lsp.extras.lazydev"),
|
||||||
require("plugins.lsp.extras.gopher"),
|
require("plugins.lsp.extras.gopher"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Key mappings for LSP
|
|
||||||
local function setup_keymaps(bufnr)
|
local function setup_keymaps(bufnr)
|
||||||
local BORDER = "rounded"
|
local opts = { buffer = bufnr, noremap = true, silent = true }
|
||||||
local keymaps = {
|
local keymaps = {
|
||||||
{ "<C-h>", vim.lsp.buf.signature_help, "Signature Help", border = BORDER },
|
{ "K", vim.lsp.buf.hover, desc = "Hover Doc", border = "rounded" },
|
||||||
{ "K", vim.lsp.buf.hover, "Hover Doc", border = BORDER },
|
{ "<C-h>", vim.lsp.buf.signature_help, desc = "Signature Help", border = "rounded" },
|
||||||
{ "<leader>cw", vim.lsp.buf.rename, "Rename" },
|
{ "<leader>rn", vim.lsp.buf.rename, desc = "Rename" },
|
||||||
{ "<leader>r", vim.lsp.buf.rename, "Rename" },
|
{ "<leader>ca", vim.lsp.buf.code_action, desc = "Code Action" },
|
||||||
{ "vd", vim.diagnostic.open_float, "Open Diagnostics" },
|
{ "gd", require("fzf-lua").lsp_definitions, desc = "Go to Definition" },
|
||||||
{ "<leader>lr", ":LspRestart<CR>", "Restart LSP" },
|
{ "gr", require("fzf-lua").lsp_references, desc = "Go to References" },
|
||||||
{ "<leader>li", ":LspInfo<CR>", "LSP Info" },
|
{ "gD", vim.lsp.buf.declaration, desc = "Go to Declaration" },
|
||||||
{ "gd", require("fzf-lua").lsp_definitions, "Go to Definition" },
|
{ "gi", require("fzf-lua").lsp_implementations, desc = "Go to Implementation" },
|
||||||
{ "gr", require("fzf-lua").lsp_references, "Go to References" },
|
{ "gt", require("fzf-lua").lsp_typedefs, desc = "Go to Type Definition" },
|
||||||
{ "gD", vim.lsp.buf.declaration, "Go to Declaration" },
|
{ "<leader>vd", vim.diagnostic.open_float, desc = "View Diagnostics" },
|
||||||
{ "gi", require("fzf-lua").lsp_implementations, "Go to Implementation" },
|
{ "<leader>dl", require("fzf-lua").diagnostics_document, desc = "Document Diagnostics" },
|
||||||
{ "gt", require("fzf-lua").lsp_typedefs, "Go to Type Definition" },
|
{ "<leader>dw", require("fzf-lua").diagnostics_workspace, desc = "Workspace Diagnostics" },
|
||||||
{ "<leader>ca", vim.lsp.buf.code_action, "Code Action" },
|
{ "<leader>ds", require("fzf-lua").lsp_document_symbols, desc = "Document Symbols" },
|
||||||
{ "<leader>dl", require("fzf-lua").diagnostics_document, "Document Diagnostics" },
|
{ "<leader>ws", require("fzf-lua").lsp_workspace_symbols, desc = "Workspace Symbols" },
|
||||||
{ "<leader>dw", require("fzf-lua").diagnostics_workspace, "Workspace Diagnostics" },
|
{ "<leader>lr", ":LspRestart<CR>", desc = "Restart LSP" },
|
||||||
{ "<leader>ds", require("fzf-lua").lsp_document_symbols, "Document Symbols" },
|
{ "<leader>li", ":LspInfo<CR>", desc = "LSP Info" },
|
||||||
{ "<leader>ws", require("fzf-lua").lsp_workspace_symbols, "Workspace Symbols" },
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, map in ipairs(keymaps) do
|
for _, map in ipairs(keymaps) do
|
||||||
vim.keymap.set("n", map[1], function()
|
nmap(map[1], map[2], vim.tbl_extend("force", opts, { desc = map[3], border = map[4] }))
|
||||||
map[2](map[4] and { border = map[4] } or nil)
|
|
||||||
end, { buffer = bufnr, desc = map[3] })
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.config()
|
function M.config()
|
||||||
-- Mason setup
|
|
||||||
require("mason").setup({ max_concurrent_installers = 4 })
|
require("mason").setup({ max_concurrent_installers = 4 })
|
||||||
|
require("fidget").setup({})
|
||||||
|
|
||||||
-- Diagnostic configuration
|
-- Diagnostic configuration
|
||||||
vim.diagnostic.config({
|
vim.diagnostic.config({
|
||||||
severity_sort = true,
|
virtual_text = { spacing = 2, source = "if_many" },
|
||||||
float = { border = "rounded", source = "if_many" },
|
float = { border = "rounded", source = "if_many" },
|
||||||
underline = { severity = vim.diagnostic.severity.ERROR },
|
severity_sort = true,
|
||||||
signs = vim.g.have_nerd_font and {
|
signs = vim.g.have_nerd_font and {
|
||||||
text = {
|
text = {
|
||||||
[vim.diagnostic.severity.ERROR] = " ",
|
[vim.diagnostic.severity.ERROR] = "",
|
||||||
[vim.diagnostic.severity.WARN] = " ",
|
[vim.diagnostic.severity.WARN] = "",
|
||||||
[vim.diagnostic.severity.INFO] = " ",
|
[vim.diagnostic.severity.INFO] = "",
|
||||||
[vim.diagnostic.severity.HINT] = " ",
|
[vim.diagnostic.severity.HINT] = "",
|
||||||
},
|
},
|
||||||
} or {},
|
} or {},
|
||||||
virtual_text = {
|
|
||||||
source = "if_many",
|
|
||||||
spacing = 2,
|
|
||||||
format = function(diagnostic)
|
|
||||||
return diagnostic.message
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Servers and tools
|
-- List of servers to enable (matching files in ~/.config/nvim/lsp/)
|
||||||
local servers = {
|
local servers = {
|
||||||
"gopls",
|
"gopls",
|
||||||
"jsonls",
|
"jsonls",
|
||||||
|
@ -78,7 +62,6 @@ function M.config()
|
||||||
"yamlls",
|
"yamlls",
|
||||||
"graphql",
|
"graphql",
|
||||||
"html",
|
"html",
|
||||||
"jsonls",
|
|
||||||
"omnisharp",
|
"omnisharp",
|
||||||
"svelte",
|
"svelte",
|
||||||
"vtsls",
|
"vtsls",
|
||||||
|
@ -86,11 +69,16 @@ function M.config()
|
||||||
"templ",
|
"templ",
|
||||||
}
|
}
|
||||||
|
|
||||||
local ensure_installed = vim.tbl_filter(function(s)
|
-- Servers not supported by mason-lspconfig
|
||||||
return s ~= "ccls"
|
local mason_unsupported = { "ccls" }
|
||||||
|
|
||||||
|
-- Filter supported servers for mason-lspconfig
|
||||||
|
local mason_servers = vim.tbl_filter(function(server)
|
||||||
|
return not vim.tbl_contains(mason_unsupported, server)
|
||||||
end, servers)
|
end, servers)
|
||||||
|
|
||||||
vim.list_extend(ensure_installed, {
|
-- Tools
|
||||||
|
local tools = {
|
||||||
"prettierd",
|
"prettierd",
|
||||||
"shfmt",
|
"shfmt",
|
||||||
"stylua",
|
"stylua",
|
||||||
|
@ -98,61 +86,50 @@ function M.config()
|
||||||
"clang-format",
|
"clang-format",
|
||||||
"csharpier",
|
"csharpier",
|
||||||
"quick-lint-js",
|
"quick-lint-js",
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Mason-LSPconfig setup for automatic installation
|
||||||
|
require("mason-lspconfig").setup({
|
||||||
|
ensure_installed = mason_servers,
|
||||||
|
automatic_installation = true,
|
||||||
|
automatic_enable = true,
|
||||||
})
|
})
|
||||||
|
|
||||||
require("mason-tool-installer").setup({ ensure_installed = ensure_installed })
|
-- Mason tool installer for tools and ccls
|
||||||
|
require("mason-tool-installer").setup({ ensure_installed = tools })
|
||||||
|
|
||||||
-- Document highlight autocommands
|
-- Enable LSP servers
|
||||||
local function setup_autocommands(client, bufnr)
|
vim.lsp.enable(servers)
|
||||||
if client.server_capabilities.documentHighlightProvider then
|
|
||||||
local group = vim.api.nvim_create_augroup("LSPDocumentHighlight", { clear = true })
|
|
||||||
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
|
|
||||||
group = group,
|
|
||||||
buffer = bufnr,
|
|
||||||
callback = vim.lsp.buf.document_highlight,
|
|
||||||
})
|
|
||||||
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
|
|
||||||
group = group,
|
|
||||||
buffer = bufnr,
|
|
||||||
callback = vim.lsp.buf.clear_references,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- LspAttach autocommand
|
-- LSP Attach
|
||||||
vim.api.nvim_create_autocmd("LspAttach", {
|
vim.api.nvim_create_autocmd("LspAttach", {
|
||||||
group = vim.api.nvim_create_augroup("kickstart-lsp-attach", { clear = true }),
|
group = vim.api.nvim_create_augroup("UserLspConfig", { clear = true }),
|
||||||
callback = function(event)
|
callback = function(args)
|
||||||
local client = vim.lsp.get_client_by_id(event.data.client_id)
|
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||||
local bufnr = event.buf
|
local bufnr = args.buf
|
||||||
setup_keymaps(bufnr)
|
|
||||||
setup_autocommands(client, bufnr)
|
|
||||||
|
|
||||||
-- Inlay hints toggle
|
setup_keymaps(bufnr)
|
||||||
if client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint, { bufnr = bufnr }) then
|
|
||||||
|
-- Inlay hints
|
||||||
|
if client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then
|
||||||
vim.keymap.set("n", "<leader>th", function()
|
vim.keymap.set("n", "<leader>th", function()
|
||||||
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = bufnr }))
|
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = bufnr }))
|
||||||
end, { buffer = bufnr, desc = "Toggle Inlay Hints" })
|
end, { buffer = bufnr, desc = "Toggle Inlay Hints" })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Document highlights
|
||||||
|
if client.server_capabilities.documentHighlightProvider then
|
||||||
|
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
|
||||||
|
buffer = bufnr,
|
||||||
|
callback = vim.lsp.buf.document_highlight,
|
||||||
|
})
|
||||||
|
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
|
||||||
|
buffer = bufnr,
|
||||||
|
callback = vim.lsp.buf.clear_references,
|
||||||
|
})
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Base LSP configuration
|
|
||||||
local base_config = {
|
|
||||||
capabilities = require("blink.cmp").get_lsp_capabilities(),
|
|
||||||
flags = { debounce_text_changes = 150 },
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Setup LSP servers
|
|
||||||
require("mason-lspconfig").setup({ ensure_installed = {}, automatic_installation = true, automatic_enable = false })
|
|
||||||
for _, server in ipairs(servers) do
|
|
||||||
local config = vim.deepcopy(base_config)
|
|
||||||
local ok, server_opts = pcall(require, "config.lsp." .. server)
|
|
||||||
if ok then
|
|
||||||
config = vim.tbl_deep_extend("force", config, server_opts)
|
|
||||||
end
|
|
||||||
require("lspconfig")[server].setup(config)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue