-- Native LSP — no nvim-lspconfig plugin required. -- Server configs live in ~/.config/nvim/lsp/ -- Servers must be on your PATH (install via npm/pip/dnf etc.) -- Global capabilities applied to every server vim.lsp.config("*", { capabilities = { textDocument = { completion = { completionItem = { snippetSupport = true, resolveSupport = { properties = { "documentation", "detail", "additionalTextEdits" }, }, }, }, }, }, }) -- Enable servers (configs are in lsp/ directory) vim.lsp.enable({ "ts_ls", "bashls", "cssls", "eslint", "html", "jsonls", "ruff", "pyright", "yamlls", "marksman", "clangd", }) -- Per-buffer setup on attach vim.api.nvim_create_autocmd("LspAttach", { group = vim.api.nvim_create_augroup("user.lsp", { clear = true }), callback = function(ev) local client = vim.lsp.get_client_by_id(ev.data.client_id) local buf = ev.buf -- Native completion (0.12) if client and client:supports_method("textDocument/completion") then vim.lsp.completion.enable(true, client.id, buf, { autotrigger = true }) end -- Format on save if client and client:supports_method("textDocument/formatting") then vim.api.nvim_create_autocmd("BufWritePre", { group = vim.api.nvim_create_augroup("user.lsp.format." .. buf, { clear = true }), buffer = buf, callback = function() vim.lsp.buf.format({ bufnr = buf, id = client.id }) end, }) end -- Keymaps (replaces lspsaga bindings) -- 0.12 provides gra, grn, grr, gri, gO, K globally by default. -- These add your existing bindings on top: local map = function(keys, fn, desc) vim.keymap.set("n", keys, fn, { buffer = buf, desc = desc }) end map("gd", vim.lsp.buf.definition, "Go to definition") map("gf", vim.lsp.buf.definition, "Go to definition (alt)") map("g", vim.lsp.buf.definition, "Peek definition (native fallback)") map("K", vim.lsp.buf.hover, "Hover doc") map("y", vim.lsp.buf.references, "References") map("rn", vim.lsp.buf.rename, "Rename") map("b", vim.lsp.buf.code_action, "Code action") map("r", vim.diagnostic.open_float,"Show line diagnostics") map("[d", vim.diagnostic.goto_prev, "Previous diagnostic") map("]d", vim.diagnostic.goto_next, "Next diagnostic") end, })