2024-02-19 21:33:56 +03:00
if true then return { } end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE
2023-07-27 19:42:05 +03:00
-- AstroLSP allows you to customize the features in AstroNvim's LSP configuration engine
2024-02-14 19:12:47 +03:00
-- Configuration documentation can be found with `:h astrolsp`
2024-02-23 23:53:28 +03:00
-- NOTE: We highly recommend setting up the Lua Language Server (`:LspInstall lua_ls`)
-- as this provides autocomplete and documentation while editing
2024-02-14 19:12:47 +03:00
2024-01-20 08:40:08 +03:00
---@type LazySpec
2023-07-27 19:42:05 +03:00
return {
" AstroNvim/astrolsp " ,
2023-08-03 22:40:31 +03:00
---@type AstroLSPOpts
2023-07-27 19:42:05 +03:00
opts = {
2024-01-22 21:09:26 +03:00
-- 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
} ,
2023-07-27 19:42:05 +03:00
-- customize lsp formatting options
formatting = {
-- control auto formatting on save
format_on_save = {
enabled = true , -- enable or disable format on save globally
} ,
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
2024-05-05 00:47:39 +03:00
" lua_ls " ,
2023-07-27 19:42:05 +03:00
} ,
2024-05-05 00:47:39 +03:00
timeout_ms = 4000 , -- default format timeout
2023-07-27 19:42:05 +03:00
-- filter = function(client) -- fully override the default formatting function
-- return true
-- end
} ,
-- enable servers that you already have installed without mason
servers = {
2024-05-05 00:47:39 +03:00
" pyright " ,
" black " ,
" isort "
2023-07-27 19:42:05 +03:00
} ,
-- customize language server configuration options passed to `lspconfig`
2023-10-26 17:36:27 +03:00
---@diagnostic disable: missing-fields
2023-07-27 19:42:05 +03:00
config = {
-- clangd = { capabilities = { offsetEncoding = "utf-8" } },
} ,
-- customize how language servers are attached
2024-02-14 19:12:47 +03:00
handlers = {
2023-07-27 19:42:05 +03:00
-- 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
} ,
2024-02-14 19:12:47 +03:00
-- Configure buffer local auto commands to add when attaching a language server
autocmds = {
-- first key is the `augroup` to add the auto commands to (:h augroup)
lsp_document_highlight = {
-- Optional condition to create/delete auto command group
-- can either be a string of a client capability or a function of `fun(client, bufnr): boolean`
-- condition will be resolved for each client on each execution and if it ever fails for all clients,
-- the auto commands will be deleted for that buffer
cond = " textDocument/documentHighlight " ,
-- cond = function(client, bufnr) return client.name == "lua_ls" end,
-- list of auto commands to set
{
-- events to trigger
event = { " CursorHold " , " CursorHoldI " } ,
-- the rest of the autocmd options (:h nvim_create_autocmd)
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 ,
} ,
} ,
} ,
2023-07-27 19:42:05 +03:00
-- mappings to be set up on attaching of a language server
mappings = {
n = {
gl = { function ( ) vim.diagnostic . open_float ( ) end , desc = " Hover diagnostics " } ,
-- a `cond` key can provided as the string of a server capability to be required to attach, or a function with `client` and `bufnr` parameters from the `on_attach` that returns a boolean
-- gD = {
-- function() vim.lsp.buf.declaration() end,
-- desc = "Declaration of current symbol",
-- cond = "textDocument/declaration",
-- },
2024-01-28 17:58:38 +03:00
-- ["<Leader>uY"] = {
2023-07-27 19:42:05 +03:00
-- function() require("astrolsp.toggles").buffer_semantic_tokens() end,
-- desc = "Toggle LSP semantic highlight (buffer)",
-- cond = function(client) return client.server_capabilities.semanticTokensProvider and vim.lsp.semantic_tokens end,
-- },
} ,
} ,
2024-02-14 19:12:47 +03:00
-- A custom `on_attach` function to be run after the default `on_attach` function
-- takes two parameters `client` and `bufnr` (`:h lspconfig-setup`)
on_attach = function ( client , bufnr )
-- this would disable semanticTokensProvider for all clients
-- client.server_capabilities.semanticTokensProvider = nil
end ,
2023-07-27 19:42:05 +03:00
} ,
}