---@type LazySpec return { "AstroNvim/astrolsp", ---@type AstroLSPOpts opts = { -- Configuration table of features provided by AstroLSP features = { autoformat = true, -- enable or disable auto formatting on start codelens = true, -- enable/disable codelens refresh on start inlay_hints = false, -- enable/disable inlay hints on start semantic_tokens = true, -- enable/disable semantic token highlighting }, -- customize lsp formatting options formatting = { -- control auto formatting on save format_on_save = { enabled = true, -- enable or disable format on save globally allow_filetypes = { -- enable format on save for specified filetypes only "go", "python", "rust", }, ignore_filetypes = { -- disable format on save for specified filetypes -- "python", "htmldjango", "html", }, }, disabled = { -- disable formatting capabilities for the listed language servers -- disable lua_ls formatting capability if you want to use StyLua to format your lua code -- "lua_ls", }, timeout_ms = 10000, -- default format timeout -- filter = function(client) -- fully override the default formatting function -- return true -- end }, -- enable servers that you already have installed without mason servers = { -- "pyright" }, -- customize language server configuration options passed to `lspconfig` ---@diagnostic disable: missing-fields config = { -- clangd = { capabilities = { offsetEncoding = "utf-8" } }, pyright = { settings = { python = { analysis = { autoSearchPaths = true, diagnosticMode = "workspace", useLibraryCodeForTypes = true, typeCheckingMode = "off", }, }, }, } }, -- customize how language servers are attached handlers = { -- a function without a key is simply the default handler, functions take two parameters, the server name and the configured options table for that server -- function(server, opts) require("lspconfig")[server].setup(opts) end -- the key is the server that is being setup with `lspconfig` -- rust_analyzer = false, -- setting a handler to false will disable the set up of that language server -- pyright = function(_, opts) require("lspconfig").pyright.setup(opts) end -- or a custom handler function can be passed }, autocmds = { lsp_document_highlight = { cond = "textDocument/documentHighlight", { event = { "CursorHold", "CursorHoldI" }, desc = "Document Highlighting", callback = function() vim.lsp.buf.document_highlight() end, }, { event = { "CursorMoved", "CursorMovedI", "BufLeave" }, desc = "Document Highlighting Clear", callback = function() vim.lsp.buf.clear_references() end, }, }, lsp_codelens_refresh = { cond = "textDocument/codeLens", { event = { "InsertLeave", "BufEnter" }, desc = "Refresh codelens (buffer)", callback = function(args) if require("astrolsp").config.features.codelens then vim.lsp.codelens.refresh { bufnr = args.buf } end end, }, }, }, mappings = { n = { gD = { function() vim.lsp.buf.declaration() end, desc = "Declaration of current symbol", cond = "textDocument/declaration", }, ["uY"] = { function() require("astrolsp.toggles").buffer_semantic_tokens() end, desc = "Toggle LSP semantic highlight (buffer)", cond = function(client) return client.supports_method "textDocument/semanticTokens/full" and vim.lsp.semantic_tokens ~= nil end, }, }, }, on_attach = function(client, bufnr) end, }, }