diff --git a/lua/lazyvim/plugins/lsp/init.lua b/lua/lazyvim/plugins/lsp/init.lua index a2b76326..2896417b 100644 --- a/lua/lazyvim/plugins/lsp/init.lua +++ b/lua/lazyvim/plugins/lsp/init.lua @@ -10,103 +10,105 @@ return { "williamboman/mason-lspconfig.nvim", }, ---@class PluginLspOpts - opts = { - -- options for vim.diagnostic.config() - ---@type vim.diagnostic.Opts - diagnostics = { - underline = true, - update_in_insert = false, - virtual_text = { - spacing = 4, - source = "if_many", - prefix = "●", - -- this will set set the prefix to a function that returns the diagnostics icon based on the severity - -- this only works on a recent 0.10.0 build. Will be set to "●" when not supported - -- prefix = "icons", - }, - severity_sort = true, - signs = { - text = { - [vim.diagnostic.severity.ERROR] = LazyVim.config.icons.diagnostics.Error, - [vim.diagnostic.severity.WARN] = LazyVim.config.icons.diagnostics.Warn, - [vim.diagnostic.severity.HINT] = LazyVim.config.icons.diagnostics.Hint, - [vim.diagnostic.severity.INFO] = LazyVim.config.icons.diagnostics.Info, + opts = function() + return { + -- options for vim.diagnostic.config() + ---@type vim.diagnostic.Opts + diagnostics = { + underline = true, + update_in_insert = false, + virtual_text = { + spacing = 4, + source = "if_many", + prefix = "●", + -- this will set set the prefix to a function that returns the diagnostics icon based on the severity + -- this only works on a recent 0.10.0 build. Will be set to "●" when not supported + -- prefix = "icons", + }, + severity_sort = true, + signs = { + text = { + [vim.diagnostic.severity.ERROR] = LazyVim.config.icons.diagnostics.Error, + [vim.diagnostic.severity.WARN] = LazyVim.config.icons.diagnostics.Warn, + [vim.diagnostic.severity.HINT] = LazyVim.config.icons.diagnostics.Hint, + [vim.diagnostic.severity.INFO] = LazyVim.config.icons.diagnostics.Info, + }, }, }, - }, - -- Enable this to enable the builtin LSP inlay hints on Neovim >= 0.10.0 - -- Be aware that you also will need to properly configure your LSP server to - -- provide the inlay hints. - inlay_hints = { - enabled = true, - }, - -- Enable this to enable the builtin LSP code lenses on Neovim >= 0.10.0 - -- Be aware that you also will need to properly configure your LSP server to - -- provide the code lenses. - codelens = { - enabled = false, - }, - -- Enable lsp cursor word highlighting - document_highlight = { - enabled = true, - }, - -- add any global capabilities here - capabilities = {}, - -- options for vim.lsp.buf.format - -- `bufnr` and `filter` is handled by the LazyVim formatter, - -- but can be also overridden when specified - format = { - formatting_options = nil, - timeout_ms = nil, - }, - -- LSP Server Settings - ---@type lspconfig.options - servers = { - lua_ls = { - -- mason = false, -- set to false if you don't want this server to be installed with mason - -- Use this to add any additional keymaps - -- for specific lsp servers - ---@type LazyKeysSpec[] - -- keys = {}, - settings = { - Lua = { - workspace = { - checkThirdParty = false, - }, - codeLens = { - enable = true, - }, - completion = { - callSnippet = "Replace", - }, - doc = { - privateName = { "^_" }, - }, - hint = { - enable = true, - setType = false, - paramType = true, - paramName = "Disable", - semicolon = "Disable", - arrayIndex = "Disable", + -- Enable this to enable the builtin LSP inlay hints on Neovim >= 0.10.0 + -- Be aware that you also will need to properly configure your LSP server to + -- provide the inlay hints. + inlay_hints = { + enabled = true, + }, + -- Enable this to enable the builtin LSP code lenses on Neovim >= 0.10.0 + -- Be aware that you also will need to properly configure your LSP server to + -- provide the code lenses. + codelens = { + enabled = false, + }, + -- Enable lsp cursor word highlighting + document_highlight = { + enabled = true, + }, + -- add any global capabilities here + capabilities = {}, + -- options for vim.lsp.buf.format + -- `bufnr` and `filter` is handled by the LazyVim formatter, + -- but can be also overridden when specified + format = { + formatting_options = nil, + timeout_ms = nil, + }, + -- LSP Server Settings + ---@type lspconfig.options + servers = { + lua_ls = { + -- mason = false, -- set to false if you don't want this server to be installed with mason + -- Use this to add any additional keymaps + -- for specific lsp servers + ---@type LazyKeysSpec[] + -- keys = {}, + settings = { + Lua = { + workspace = { + checkThirdParty = false, + }, + codeLens = { + enable = true, + }, + completion = { + callSnippet = "Replace", + }, + doc = { + privateName = { "^_" }, + }, + hint = { + enable = true, + setType = false, + paramType = true, + paramName = "Disable", + semicolon = "Disable", + arrayIndex = "Disable", + }, }, }, }, }, - }, - -- you can do any additional lsp server setup here - -- return true if you don't want this server to be setup with lspconfig - ---@type table - setup = { - -- example to setup with typescript.nvim - -- tsserver = function(_, opts) - -- require("typescript").setup({ server = opts }) - -- return true - -- end, - -- Specify * to use this function as a fallback for any server - -- ["*"] = function(server, opts) end, - }, - }, + -- you can do any additional lsp server setup here + -- return true if you don't want this server to be setup with lspconfig + ---@type table + setup = { + -- example to setup with typescript.nvim + -- tsserver = function(_, opts) + -- require("typescript").setup({ server = opts }) + -- return true + -- end, + -- Specify * to use this function as a fallback for any server + -- ["*"] = function(server, opts) end, + }, + } + end, ---@param opts PluginLspOpts config = function(_, opts) if LazyVim.has("neoconf.nvim") then