From 43af656a9e1325e76c69e6f5e694214156c278f1 Mon Sep 17 00:00:00 2001 From: Marcelo Date: Sun, 30 Mar 2025 04:26:45 -0300 Subject: Replace nvim-lspconfig and blink completion with NVIM 0.11 native options. --- lua/config/lsp.lua | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 lua/config/lsp.lua (limited to 'lua/config/lsp.lua') diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua new file mode 100644 index 0000000..ebb779f --- /dev/null +++ b/lua/config/lsp.lua @@ -0,0 +1,82 @@ +vim.o.completeopt = "menuone,noselect,noinsert,popup,fuzzy" + +vim.diagnostic.config({ + underline = true, + virtual_lines = { current_line = true }, + signs = { + text = { + [vim.diagnostic.severity.ERROR] = "", + [vim.diagnostic.severity.WARN] = "", + [vim.diagnostic.severity.INFO] = "", + [vim.diagnostic.severity.HINT] = "", + }, + }, +}) + +vim.lsp.config("*", { + capabilities = { + textDocument = { + semanticTokens = { + multilineTokenSupport = true, + }, + completion = { + completionItem = { + snippetSupport = true, + commitCharactersSupport = true, + deprecatedSupport = true, + preselectSupport = true, + insertReplaceSupport = true, + labelDetailsSupport = true, + resolveSupport = { + properties = { + "documentation", + "detail", + "additionalTextEdits", + }, + }, + }, + }, + }, + }, + + on_attach = function(client, bufnr) + if client:supports_method('textDocument/completion') then + vim.lsp.completion.enable(true, client.id, bufnr, { autotrigger = true }) + vim.keymap.set("i", "", vim.lsp.completion.get, { buffer = bufnr }) + end + + if client:supports_method('textDocument/definition') then + vim.keymap.set("n", "grd", vim.lsp.buf.definition, { desc = "Jumps to definition", buffer = bufnr }) + end + if client:supports_method('textDocument/declaration') then + vim.keymap.set("n", "grD", vim.lsp.buf.declaration, { desc = "Jumps to declaration", buffer = bufnr }) + end + + if client:supports_method("textDocument/inlayHint") then + vim.lsp.inlay_hint.enable(true, { bufnr }) + end + + if client:supports_method("textDocument/formatting") then + local description = "LSP: Formats the current buffer" + local format_buffer = function() + vim.lsp.buf.format({ async = true, buffer = bufnr }) + end + vim.keymap.set("n", "cf", format_buffer, { desc = description }) + vim.keymap.set("v", "", format_buffer, { desc = description }) + end + end, +}) + +vim.lsp.enable({ + "clangd", + "css", + "go", + "html", + "javascript", + "json", + "lua", + "markdown", + "odin", + "ruby", + "yaml", +}) -- cgit v1.2.3