dev: automated commit - 2025-12-22 16:25:06
This commit is contained in:
parent
a0e3cf85df
commit
097db10b9f
10 changed files with 107 additions and 240 deletions
|
|
@ -11,7 +11,6 @@ M.config = function()
|
|||
|
||||
lint.linters_by_ft = {
|
||||
-- fuck this shit, 1.5Gb of RAM for this crap
|
||||
--
|
||||
-- javascript = {"eslint_d"},
|
||||
-- typescript = {"eslint_d"},
|
||||
-- javascriptreact = {"eslint_d"},
|
||||
|
|
|
|||
94
lua/plugins/lsp.lua
Normal file
94
lua/plugins/lsp.lua
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
local M = {
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = {
|
||||
{
|
||||
"folke/lazydev.nvim",
|
||||
ft = "lua",
|
||||
opts = {
|
||||
library = {
|
||||
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"j-hui/fidget.nvim",
|
||||
opts = {},
|
||||
},
|
||||
{
|
||||
"ray-x/go.nvim",
|
||||
ft = "go",
|
||||
config = function(_, opts)
|
||||
require("go").setup(opts)
|
||||
vim.keymap.set("n", "<leader>gmt", ":GoModTidy<cr>", {
|
||||
desc = "[Go] Tidy",
|
||||
})
|
||||
end,
|
||||
build = function()
|
||||
vim.cmd([[silent! GoModTidy]])
|
||||
end,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
function M.config()
|
||||
local lspconfig = require("lspconfig")
|
||||
|
||||
vim.lsp.enable({ "tsgo" })
|
||||
|
||||
local servers = {
|
||||
"gopls",
|
||||
"jsonls",
|
||||
"clangd",
|
||||
"lua_ls",
|
||||
"yamlls",
|
||||
"graphql",
|
||||
"html",
|
||||
"cssls",
|
||||
"omnisharp",
|
||||
"svelte",
|
||||
"templ",
|
||||
"tinymist",
|
||||
"jdtls",
|
||||
"nixd",
|
||||
"qmlls",
|
||||
"zls",
|
||||
}
|
||||
|
||||
for _, server in ipairs(servers) do
|
||||
lspconfig[server].setup({})
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = vim.api.nvim_create_augroup("lsp", { clear = true }),
|
||||
callback = function(ev)
|
||||
local opts = { buffer = ev.buf, silent = true }
|
||||
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
||||
|
||||
nmap("K", vim.lsp.buf.hover, vim.tbl_extend("force", opts, { desc = "Hover Doc" }))
|
||||
nmap("<C-h>", vim.lsp.buf.signature_help, vim.tbl_extend("force", opts, { desc = "Signature Help" }))
|
||||
nmap("<leader>r", vim.lsp.buf.rename, vim.tbl_extend("force", opts, { desc = "Rename" }))
|
||||
nmap("<leader>ca", vim.lsp.buf.code_action, vim.tbl_extend("force", opts, { desc = "Code Action" }))
|
||||
nmap("vd", vim.diagnostic.open_float, vim.tbl_extend("force", opts, { desc = "View Diagnostics" }))
|
||||
nmap("<leader>lr", "<cmd>LspRestart<CR>", vim.tbl_extend("force", opts, { desc = "Restart LSP" }))
|
||||
|
||||
if client and client.server_capabilities.documentHighlightProvider then
|
||||
local hl_group = vim.api.nvim_create_augroup("lsp_document_highlight_" .. ev.buf, { clear = true })
|
||||
|
||||
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
|
||||
group = hl_group,
|
||||
buffer = ev.buf,
|
||||
callback = vim.lsp.buf.document_highlight,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
|
||||
group = hl_group,
|
||||
buffer = ev.buf,
|
||||
callback = vim.lsp.buf.clear_references,
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
||||
--
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
return {
|
||||
"ray-x/go.nvim",
|
||||
ft = "go",
|
||||
config = function(_, opts)
|
||||
require("go").setup(opts)
|
||||
vim.keymap.set("n", "<leader>gmt", ":GoModTidy<cr>", {
|
||||
desc = "[Go] Tidy",
|
||||
})
|
||||
end,
|
||||
build = function()
|
||||
vim.cmd([[silent! GoModTidy]])
|
||||
end,
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
return {
|
||||
"folke/lazydev.nvim",
|
||||
ft = "lua",
|
||||
opts = {
|
||||
library = {
|
||||
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -1,186 +0,0 @@
|
|||
return {
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = {
|
||||
require("plugins.lsp.extras.lazydev"),
|
||||
require("plugins.lsp.extras.gopher"),
|
||||
"j-hui/fidget.nvim",
|
||||
"ibhagwan/fzf-lua",
|
||||
},
|
||||
|
||||
config = function()
|
||||
require("fidget").setup({})
|
||||
|
||||
-- Enhance floating preview windows
|
||||
local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview
|
||||
function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...)
|
||||
opts = opts or {}
|
||||
opts.border = opts.border or "rounded"
|
||||
opts.max_width = opts.max_width or 80
|
||||
opts.max_height = opts.max_height or 20
|
||||
return orig_util_open_floating_preview(contents, syntax, opts, ...)
|
||||
end
|
||||
|
||||
-- Diagnostics configuration
|
||||
vim.diagnostic.config({
|
||||
virtual_text = { spacing = 2, source = "if_many" },
|
||||
float = { border = "rounded", source = "if_many" },
|
||||
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 true,
|
||||
underline = true,
|
||||
update_in_insert = true,
|
||||
severity_sort = true,
|
||||
})
|
||||
|
||||
-- Global floating options
|
||||
_G.floating_options = {
|
||||
focusable = true,
|
||||
focus = false,
|
||||
max_height = 50,
|
||||
max_width = 100,
|
||||
}
|
||||
|
||||
-- Auto-format on save
|
||||
-- vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
-- callback = function()
|
||||
-- if vim.lsp.buf_is_attached() then
|
||||
-- vim.lsp.buf.format()
|
||||
-- end
|
||||
-- end,
|
||||
-- })
|
||||
|
||||
-- Filter out unwanted code actions
|
||||
vim.lsp.buf.code_action = (function(orig)
|
||||
return function(opts)
|
||||
opts = opts or {}
|
||||
opts.filter = function(action)
|
||||
if not action then
|
||||
return false
|
||||
end
|
||||
-- Ignore gopls "Browse" actions
|
||||
if action.title and action.title:match("Browse gopls") then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
return orig(opts)
|
||||
end
|
||||
end)(vim.lsp.buf.code_action)
|
||||
|
||||
-- Keymaps setup function
|
||||
local function setup_keymaps(bufnr)
|
||||
local fzf = require("fzf-lua")
|
||||
local opts = { buffer = bufnr }
|
||||
|
||||
-- Helper function for mapping
|
||||
local function nmap(key, func, desc_opts)
|
||||
vim.keymap.set("n", key, func, desc_opts)
|
||||
end
|
||||
|
||||
-- Basic LSP
|
||||
nmap("K", vim.lsp.buf.hover, vim.tbl_extend("force", opts, { desc = "Hover Doc" }))
|
||||
nmap("<C-h>", vim.lsp.buf.signature_help, vim.tbl_extend("force", opts, { desc = "Signature Help" }))
|
||||
nmap("<leader>r", vim.lsp.buf.rename, vim.tbl_extend("force", opts, { desc = "Rename" }))
|
||||
nmap("<leader>ca", vim.lsp.buf.code_action, vim.tbl_extend("force", opts, { desc = "Code Action" }))
|
||||
|
||||
-- Navigation
|
||||
nmap("gd", fzf.lsp_definitions, vim.tbl_extend("force", opts, { desc = "Go to Definition" }))
|
||||
nmap("gr", fzf.lsp_references, vim.tbl_extend("force", opts, { desc = "Go to References" }))
|
||||
nmap("gD", vim.lsp.buf.declaration, vim.tbl_extend("force", opts, { desc = "Go to Declaration" }))
|
||||
nmap("gi", fzf.lsp_implementations, vim.tbl_extend("force", opts, { desc = "Go to Implementation" }))
|
||||
nmap("gt", fzf.lsp_typedefs, vim.tbl_extend("force", opts, { desc = "Go to Type Definition" }))
|
||||
|
||||
-- Diagnostics
|
||||
nmap("vd", vim.diagnostic.open_float, vim.tbl_extend("force", opts, { desc = "View Diagnostics" }))
|
||||
nmap("<leader>dl", fzf.diagnostics_document, vim.tbl_extend("force", opts, { desc = "Document Diagnostics" }))
|
||||
nmap("<leader>dw", fzf.diagnostics_workspace, vim.tbl_extend("force", opts, { desc = "Workspace Diagnostics" }))
|
||||
nmap("<leader>ds", fzf.lsp_document_symbols, vim.tbl_extend("force", opts, { desc = "Document Symbols" }))
|
||||
nmap("<leader>ws", fzf.lsp_workspace_symbols, vim.tbl_extend("force", opts, { desc = "Workspace Symbols" }))
|
||||
|
||||
-- LSP management
|
||||
nmap("<leader>lr", function()
|
||||
local clients = vim.lsp.get_clients({ bufnr = bufnr })
|
||||
if #clients == 0 then
|
||||
vim.notify("No LSP clients attached to buffer", vim.log.levels.WARN)
|
||||
return
|
||||
end
|
||||
|
||||
local client_names = {}
|
||||
for _, client in ipairs(clients) do
|
||||
table.insert(client_names, client.name)
|
||||
vim.cmd("LspRestart " .. client.name)
|
||||
end
|
||||
vim.notify("Restarted LSP clients: " .. table.concat(client_names, ", "), vim.log.levels.INFO)
|
||||
end, vim.tbl_extend("force", opts, { desc = "Restart LSP" }))
|
||||
nmap("<leader>li", ":LspInfo<CR>", vim.tbl_extend("force", opts, { desc = "LSP Info" }))
|
||||
end
|
||||
|
||||
local lspconfig = require("lspconfig")
|
||||
|
||||
-- Lista de servidores LSP a habilitar
|
||||
local servers = {
|
||||
"gopls",
|
||||
"jsonls",
|
||||
"clangd",
|
||||
"lua_ls",
|
||||
"yamlls",
|
||||
"graphql",
|
||||
"html",
|
||||
"cssls",
|
||||
"omnisharp",
|
||||
"svelte",
|
||||
"templ",
|
||||
"tinymist",
|
||||
"jdtls",
|
||||
-- "ts_ls",
|
||||
"nixd",
|
||||
}
|
||||
|
||||
-- Setup automático - Neovim 11 carga las configs automáticamente
|
||||
for _, server in ipairs(servers) do
|
||||
lspconfig[server].setup({})
|
||||
end
|
||||
|
||||
-- LSP Attach autocmd
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = vim.api.nvim_create_augroup("UserLspConfig", { clear = true }),
|
||||
callback = function(args)
|
||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
if not client then
|
||||
return
|
||||
end
|
||||
|
||||
-- Setup keymaps
|
||||
setup_keymaps(args.buf)
|
||||
|
||||
-- Inlay hints
|
||||
if client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint, args.buf) then
|
||||
vim.keymap.set("n", "<leader>th", function()
|
||||
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = args.buf }), { bufnr = args.buf })
|
||||
end, { buffer = args.buf, desc = "Toggle Inlay Hints" })
|
||||
end
|
||||
|
||||
-- Document highlights
|
||||
if client.server_capabilities.documentHighlightProvider then
|
||||
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
|
||||
buffer = args.buf,
|
||||
callback = vim.lsp.buf.document_highlight,
|
||||
})
|
||||
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
|
||||
buffer = args.buf,
|
||||
callback = vim.lsp.buf.clear_references,
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
vim.lsp.enable({
|
||||
"tsgo",
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
|
@ -17,18 +17,6 @@ local M = {
|
|||
require("mini.ai").setup({ n_lines = 500 })
|
||||
end,
|
||||
},
|
||||
{
|
||||
"echasnovski/mini.surround",
|
||||
config = function()
|
||||
-- Add/delete/replace surroundings (brackets, quotes, etc.)
|
||||
--
|
||||
-- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren
|
||||
-- - sd' - [S]urround [D]elete [']quotes
|
||||
-- - sr)' - [S]urround [R]eplace [)] [']
|
||||
require("mini.surround").setup({})
|
||||
end,
|
||||
},
|
||||
|
||||
{
|
||||
"echasnovski/mini.statusline",
|
||||
version = false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue