local M = { { "folke/trouble.nvim", config = true, dependencies = { "nvim-tree/nvim-web-devicons" }, keys = { { "xx", "Trouble diagnostics toggle", desc = "Diagnostics (Trouble)", }, { "xX", "Trouble diagnostics toggle filter.buf=0", desc = "Buffer Diagnostics (Trouble)", }, { "cs", "Trouble symbols toggle", desc = "Symbols (Trouble)", }, { "cl", "Trouble lsp toggle win.position=right", desc = "LSP Definitions / references / ... (Trouble)", }, { "xL", "Trouble loclist toggle", desc = "Location List (Trouble)", }, { "xQ", "Trouble qflist toggle", desc = "Quickfix List (Trouble)", }, }, opts = { auto_close = true, focus = true, }, }, { "j-hui/fidget.nvim", event = "BufReadPost", -- LspAttach would be ideal but we use as vim notify override opts = { notification = { override_vim_notify = true, }, }, }, { "neovim/nvim-lspconfig", event = "BufReadPre", config = function() vim.diagnostic.config({ float = { focusable = true, style = "minimal", border = "rounded", source = "always", header = "", prefix = "", severity_sort = true, }, virtual_text = { spacing = 4, prefix = "󰊠" }, signs = true, underline = true, update_in_insert = true, severity_sort = true, }) local on_attach = function(_, bufnr) local function map(modes, keys, command, desc) vim.keymap.set(modes, keys, command, { noremap = true, silent = true, buffer = bufnr, desc = desc, }) end map("n", "gr", "Telescope lsp_references", "LSP References") map("n", "gd", "Telescope lsp_definitions", "LSP Definitions") map("n", "gD", vim.lsp.buf.declaration, "LSP Declarations") map("n", "gi", "Telescope lsp_implementations", "LSP Implementations") map("n", "D", "Telescope diagnostics bufnr=0", "LSP Diagnostics") map("n", "d", vim.diagnostic.open_float, "Inline Diagnostics") map("n", "[d", vim.diagnostic.goto_prev, "Previous Diagnostic") map("n", "]d", vim.diagnostic.goto_next, "Next Diagnostic") map("n", "K", vim.lsp.buf.hover, "Symbol Info") map({ "n", "v" }, "ca", vim.lsp.buf.code_action, "Code Actions") map("n", "rn", vim.lsp.buf.rename, "Smart Rename") map("i", "", vim.lsp.buf.signature_help, "Lsp signature help") map("n", "fm", vim.lsp.buf.format, "Format Document") end local capabilities = require("blink.cmp").get_lsp_capabilities() local servers = { tinymist = { root_markers = { ".git", ".jj", "flake.nix" }, }, nil_ls = { settings = { ["nil"] = { formatting = { command = { "nixfmt" }, }, }, }, }, } local lsp_server_env = os.getenv("LSP_SERVER") if lsp_server_env and not servers[lsp_server_env] then servers[lsp_server_env] = { root_markers = { ".git", ".jj", "flake.nix" }, } end for server, config in pairs(servers) do vim.lsp.enable(server) vim.lsp.config[server] = vim.tbl_extend("force", { capabilities = capabilities, on_attach = on_attach, }, config) end end, }, } return M