From 00f3778fbf023ccf4955e7667e83ecf1d954839a Mon Sep 17 00:00:00 2001 From: "Mariano Z." Date: Mon, 22 Dec 2025 17:45:39 -0300 Subject: [PATCH] dev: automated commit - 2025-12-22 17:45:39 --- init.lua | 1 + lua/config/autocomands.lua | 13 +++++ lua/config/lsp.lua | 42 +++++++++++++++ lua/plugins/lsp.lua | 105 +++++++++---------------------------- 4 files changed, 80 insertions(+), 81 deletions(-) create mode 100644 lua/config/lsp.lua diff --git a/init.lua b/init.lua index 931cf19..7ec8b0f 100644 --- a/init.lua +++ b/init.lua @@ -7,6 +7,7 @@ require("config.options") require("config.remap") require("config.autocomands") require("config.lazy") +require("config.lsp") vim.api.nvim_create_autocmd("VimEnter", { callback = function() diff --git a/lua/config/autocomands.lua b/lua/config/autocomands.lua index 99e075c..4d3e7f6 100644 --- a/lua/config/autocomands.lua +++ b/lua/config/autocomands.lua @@ -49,3 +49,16 @@ vim.filetype.add({ }, }, }) + +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 } + nmap("K", vim.lsp.buf.hover, vim.tbl_extend("force", opts, { desc = "Hover Doc" })) + nmap("", vim.lsp.buf.signature_help, vim.tbl_extend("force", opts, { desc = "Signature Help" })) + nmap("r", vim.lsp.buf.rename, vim.tbl_extend("force", opts, { desc = "Rename" })) + nmap("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("lr", "LspRestart", vim.tbl_extend("force", opts, { desc = "Restart LSP" })) + end, +}) diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua new file mode 100644 index 0000000..38d2661 --- /dev/null +++ b/lua/config/lsp.lua @@ -0,0 +1,42 @@ +vim.lsp.enable({ + "gopls", + "jsonls", + "clangd", + "lua_ls", + "yamlls", + "graphql", + "html", + "cssls", + "omnisharp", + "svelte", + "templ", + "tinymist", + "jdtls", + "nixd", + "qmlls", + "zls", + "tsgo", +}) + +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 } + nmap("K", vim.lsp.buf.hover, vim.tbl_extend("force", opts, { desc = "Hover Doc" })) + nmap("", vim.lsp.buf.signature_help, vim.tbl_extend("force", opts, { desc = "Signature Help" })) + nmap("r", vim.lsp.buf.rename, vim.tbl_extend("force", opts, { desc = "Rename" })) + nmap("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("lr", "LspRestart", vim.tbl_extend("force", opts, { desc = "Restart LSP" })) + end, +}) + +-- 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 diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index e12f1cb..2702cb2 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -1,85 +1,28 @@ -local M = { - "neovim/nvim-lspconfig", - dependencies = { - { - "folke/lazydev.nvim", - ft = "lua", - opts = { - library = { - { path = "${3rd}/luv/library", words = { "vim%.uv" } }, - }, +return { + { + "j-hui/fidget.nvim", + opts = {}, + }, + { + "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", "gmt", ":GoModTidy", { - desc = "[Go] Tidy", - }) - end, - build = function() - vim.cmd([[silent! GoModTidy]]) - end, - }, + }, + { + "ray-x/go.nvim", + ft = "go", + config = function(_, opts) + require("go").setup(opts) + vim.keymap.set("n", "gmt", ":GoModTidy", { + 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({ - on_attach = function(client, bufnr) - local opts = { buffer = bufnr, silent = true } - - nmap("K", vim.lsp.buf.hover, vim.tbl_extend("force", opts, { desc = "Hover Doc" })) - nmap("", vim.lsp.buf.signature_help, vim.tbl_extend("force", opts, { desc = "Signature Help" })) - nmap("r", vim.lsp.buf.rename, vim.tbl_extend("force", opts, { desc = "Rename" })) - nmap("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("lr", "LspRestart", vim.tbl_extend("force", opts, { desc = "Restart LSP" })) - - 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 -end - -return M ---