dev: automated commit - 2025-05-15 22:52:48

This commit is contained in:
Mariano Z. 2025-05-15 22:52:48 -03:00
parent 6fb744cdae
commit 05ffc3930b
4 changed files with 180 additions and 198 deletions

View file

@ -1,28 +1,20 @@
local M = {
"stevearc/quicker.nvim",
-- Set plugin to load on VimEnter instead of FileType qf to ensure diagnostics are configured early
event = { "VimEnter" },
-- Add an explicit dependency for diagnostics loading
dependencies = { "nvim-lspconfig" }, -- Assuming you're using nvim-lspconfig
event = "VimEnter",
dependencies = { "neovim/nvim-lspconfig" },
}
-- Move sign registration outside of the config function to ensure it runs early
local function register_diagnostic_signs()
-- Define diagnostic sign icons
local sign_icons = {
[vim.diagnostic.severity.ERROR] = "󰅙", -- Alternative error symbol
[vim.diagnostic.severity.WARN] = "󱈸", -- Alternative warning
[vim.diagnostic.severity.HINT] = "󰮱", -- Star for hints
[vim.diagnostic.severity.INFO] = "󰋼", -- Info circle
}
-- Register signs explicitly
for severity, icon in pairs(sign_icons) do
M.init = function()
for severity, icon in pairs({
[vim.diagnostic.severity.ERROR] = icons.diagnostics.Error,
[vim.diagnostic.severity.WARN] = icons.diagnostics.Warning,
[vim.diagnostic.severity.INFO] = icons.diagnostics.Information,
[vim.diagnostic.severity.HINT] = icons.diagnostics.Hint,
}) do
local name = "DiagnosticSign" .. vim.diagnostic.severity[severity]
vim.fn.sign_define(name, { text = icon, texthl = name })
end
-- Set sign highlights for better visibility
vim.cmd([[
highlight DiagnosticSignError guifg=#f7768e gui=bold
highlight DiagnosticSignWarn guifg=#e0af68 gui=bold
@ -31,39 +23,38 @@ local function register_diagnostic_signs()
]])
end
-- This will now be called during setup() which happens at init
M.init = function()
register_diagnostic_signs()
-- Cycle through quickfix items
local function cycle_qf(cmd)
local qf = vim.fn.getqflist({ size = 0, idx = 0 })
if qf.size == 0 then
return
end
if cmd == "next" then
vim.cmd(qf.idx == qf.size and "cfirst" or "cnext")
elseif cmd == "prev" then
vim.cmd(qf.idx == 1 and "clast" or "cprev")
end
end
local function setup_diagnostic_config()
-- Define prettier diagnostic icons
local diagnostic_icons = {
[vim.diagnostic.severity.ERROR] = "󰅚", -- More prominent error symbol
[vim.diagnostic.severity.WARN] = "󰀦", -- Warning triangle
[vim.diagnostic.severity.HINT] = "󰌵", -- Lightbulb for hints
[vim.diagnostic.severity.INFO] = "󰋽", -- Information symbol
}
-- Configure diagnostics
function M.config()
-- Diagnostic configuration using _G.icons.diagnostics
-- local icons = _G.icons.diagnostics
vim.diagnostic.config({
virtual_text = {
prefix = "",
suffix = "",
format = function(diagnostic)
local icon = diagnostic_icons[diagnostic.severity] or ""
return string.format("%s %s", icon, diagnostic.message)
format = function(d)
return string.format("%s %s", icons[vim.diagnostic.severity[d.severity]], d.message)
end,
},
underline = true, -- Enable underline for better visibility
underline = true,
update_in_insert = false,
signs = {
active = true,
text = {
[vim.diagnostic.severity.ERROR] = "󰅙", -- Alternative error symbol
[vim.diagnostic.severity.WARN] = "󱈸", -- Alternative warning
[vim.diagnostic.severity.HINT] = "󰮱", -- Star for hints
[vim.diagnostic.severity.INFO] = "󰋼", -- Info circle
[vim.diagnostic.severity.ERROR] = icons.diagnostics.Error,
[vim.diagnostic.severity.WARN] = icons.diagnostics.Warning,
[vim.diagnostic.severity.INFO] = icons.diagnostics.Information,
[vim.diagnostic.severity.HINT] = icons.diagnostics.Hint,
},
},
float = {
@ -71,42 +62,20 @@ local function setup_diagnostic_config()
style = "minimal",
border = "rounded",
source = true,
header = "",
prefix = "",
format = function(diagnostic)
local severity = vim.diagnostic.severity[diagnostic.severity]
local icon = diagnostic_icons[diagnostic.severity] or ""
return string.format("%s %s: %s", icon, severity:lower(), diagnostic.message)
format = function(d)
return string.format(
"%s %s: %s",
icons[vim.diagnostic.severity[d.severity]],
vim.diagnostic.severity[d.severity]:lower(),
d.message
)
end,
},
severity_sort = true,
})
end
local function cycle_qf(cmd)
local qf_list_empty = vim.fn.getqflist({ size = 0 }).size == 0
if qf_list_empty then
return
end
local current_qf = vim.fn.getqflist({ idx = 0 }).idx
local qf_size = vim.fn.getqflist({ size = 0 }).size
if cmd == "next" then
if current_qf == qf_size then
vim.cmd("cfirst")
else
vim.cmd("cnext")
end
elseif cmd == "prev" then
if current_qf == 1 then
vim.cmd("clast")
else
vim.cmd("cprev")
end
end
end
function M.config()
local opts = {
-- Quicker setup
require("quicker").setup({
keys = {
{
">",
@ -124,21 +93,19 @@ function M.config()
},
},
type_icons = {
E = "󰅚 ", -- Error
W = "󰀦 ", -- Warning
I = "󰋽 ", -- Info
N = "󰎚 ", -- Note
H = "󰌵 ", -- Hint
E = icons.diagnostics.Error .. " ",
W = icons.diagnostics.Warning .. " ",
I = icons.diagnostics.Information .. " ",
N = icons.ui.Note .. " ",
H = icons.diagnostics.Hint .. " ",
},
}
require("quicker").setup(opts)
setup_diagnostic_config()
})
-- Replace the existing mappings with the cycling versions
nmap("<a-j>", function()
-- Quickfix navigation mappings
vim.keymap.set("n", "<a-j>", function()
cycle_qf("next")
end, { desc = "Next quickfix item (cycles)" })
nmap("<a-k>", function()
vim.keymap.set("n", "<a-k>", function()
cycle_qf("prev")
end, { desc = "Previous quickfix item (cycles)" })
end

View file

@ -2,113 +2,92 @@ local M = {
"neovim/nvim-lspconfig",
dependencies = {
"saghen/blink.cmp",
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
"WhoIsSethDaniel/mason-tool-installer.nvim",
{ "j-hui/fidget.nvim", opts = {} },
"ibhagwan/fzf-lua",
require("plugins.lsp.extras.lazydev"),
require("plugins.lsp.extras.gopher"),
},
}
-- Set up autocommands for document highlights
local function setup_autocommands(client, bufnr)
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
-- Set up key mappings for LSP functionality
-- Key mappings for LSP
local function setup_keymaps(bufnr)
local BORDER = "rounded"
local keymaps = {
{
"<C-h>",
function()
vim.lsp.buf.signature_help({ border = BORDER })
end,
"Signature Help",
},
{
"K",
function()
vim.lsp.buf.hover({ border = BORDER })
end,
"Hover Doc",
},
{ "<C-h>", vim.lsp.buf.signature_help, "Signature Help", border = BORDER },
{ "K", vim.lsp.buf.hover, "Hover Doc", border = BORDER },
{ "<leader>cw", vim.lsp.buf.rename, "Rename" },
{ "<leader>r", vim.lsp.buf.rename, "Rename" },
{ "vd", vim.diagnostic.open_float, "Open Diagnostics" },
{ "<leader>lr", ":LspRestart<CR>", "Restart LSP" },
{ "<leader>li", ":LspInfo<CR>", "LSP Info" },
{ "gd", require("fzf-lua").lsp_definitions, "Go to Definition" },
{ "gr", require("fzf-lua").lsp_references, "Go to References" },
{ "gD", vim.lsp.buf.declaration, "Go to Declaration" },
{ "gi", require("fzf-lua").lsp_implementations, "Go to Implementation" },
{ "gt", require("fzf-lua").lsp_typedefs, "Go to Type Definition" },
{ "<leader>ca", vim.lsp.buf.code_action, "Code Action" },
{ "<leader>dl", require("fzf-lua").diagnostics_document, "Document Diagnostics" },
{ "<leader>dw", require("fzf-lua").diagnostics_workspace, "Workspace Diagnostics" },
{ "<leader>ds", require("fzf-lua").lsp_document_symbols, "Document Symbols" },
{ "<leader>ws", require("fzf-lua").lsp_workspace_symbols, "Workspace Symbols" },
}
for _, map in ipairs(keymaps) do
nmap(map[1], map[2], {
buffer = bufnr,
desc = map[3],
})
vim.keymap.set("n", map[1], function()
map[2](map[4] and { border = map[4] } or nil)
end, { buffer = bufnr, desc = map[3] })
end
end
-- Function called when LSP attaches to a buffer
function M.on_attach(client, bufnr)
setup_autocommands(client, bufnr)
setup_keymaps(bufnr)
end
-- Function to get common LSP configuration
function M.get_common_config()
local capabilities = require("blink.cmp").get_lsp_capabilities()
-- Enable folding capabilities
capabilities.textDocument.foldingRange = {
dynamicRegistration = false,
lineFoldingOnly = true,
}
return {
on_attach = M.on_attach,
capabilities = capabilities,
flags = { debounce_text_changes = 150 },
}
end
function M.config()
-- Set up Mason
require("mason").setup({
max_concurrent_installers = 4,
-- Mason setup
require("mason").setup({ max_concurrent_installers = 4 })
-- Diagnostic configuration
vim.diagnostic.config({
severity_sort = true,
float = { border = "rounded", source = "if_many" },
underline = { severity = vim.diagnostic.severity.ERROR },
signs = vim.g.have_nerd_font and {
text = {
[vim.diagnostic.severity.ERROR] = "󰅚 ",
[vim.diagnostic.severity.WARN] = "󰀪 ",
[vim.diagnostic.severity.INFO] = "󰋽 ",
[vim.diagnostic.severity.HINT] = "󰌶 ",
},
} or {},
virtual_text = {
source = "if_many",
spacing = 2,
format = function(diagnostic)
return diagnostic.message
end,
},
})
-- Ensure all tools are installed
local ensure_installed = {
-- LSP servers
-- Servers and tools
local servers = {
"gopls",
"jsonls",
"lua_ls",
"yamlls",
"graphql-language-service-cli",
"html-lsp",
"htmx-lsp",
"json-lsp",
"lua-language-server",
"graphql",
"html",
"jsonls",
"omnisharp",
"yaml-language-server",
"svelte-language-server",
"svelte",
"vtsls",
-- Formatters
"ccls",
}
local ensure_installed = vim.tbl_filter(function(s)
return s ~= "ccls"
end, servers)
vim.list_extend(ensure_installed, {
"prettierd",
"shfmt",
"stylua",
@ -116,37 +95,61 @@ function M.config()
"clang-format",
"csharpier",
"quick-lint-js",
-- Additional tools
"templ",
}
})
require("mason-tool-installer").setup({ ensure_installed = ensure_installed })
-- Set up Mason LSP config
require("mason-lspconfig").setup({
ensure_installed = {}, -- explicitly set to an empty table (populated via mason-tool-installer)
automatic_installation = false,
handlers = {
function(server_name)
local base_opts = M.get_common_config()
-- Document highlight autocommands
local function setup_autocommands(client, bufnr)
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
-- Load server-specific configuration if it exists
local ok, server_opts = pcall(require, "config.lsp." .. server_name)
if ok then
base_opts = vim.tbl_deep_extend("force", base_opts, server_opts)
end
-- LspAttach autocommand
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("kickstart-lsp-attach", { clear = true }),
callback = function(event)
local client = vim.lsp.get_client_by_id(event.data.client_id)
local bufnr = event.buf
setup_keymaps(bufnr)
setup_autocommands(client, bufnr)
-- Set up the LSP server with the combined options
require("lspconfig")[server_name].setup(base_opts)
end,
},
-- Inlay hints toggle
if client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint, { bufnr = bufnr }) then
vim.keymap.set("n", "<leader>th", function()
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = bufnr }))
end, { buffer = bufnr, desc = "Toggle Inlay Hints" })
end
end,
})
-- Set up non-Mason LSP servers
local non_mason_servers = { "ccls" }
for _, server in ipairs(non_mason_servers) do
require("lspconfig")[server].setup(M.get_common_config())
-- 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

View file

@ -3,8 +3,20 @@ return {
priority = 1000,
config = function()
local snacks = require("snacks")
snacks.setup({
bigfile = { enabled = true },
input = {
enabled = true,
prompt_pos = "left",
icon_pos = "left",
expand = false,
win = {
row = 0.4,
position = "float",
border = "rounded",
},
},
debug = { enabled = true },
image = { enabled = true },
indent = { enabled = true, animate = { enabled = false } },