2 { "neovim/nvim-lspconfig",
6 { "williamboman/mason-lspconfig.nvim", config = function() end }, -- don't configure yet
8 ---@class PluginLspOpts
10 ---@type vim.diagnostic.Opts
13 update_in_insert = false,
22 [vim.diagnostic.severity.ERROR] = " ",
23 [vim.diagnostic.severity.WARN] = " ",
24 [vim.diagnostic.severity.HINT] = " ",
25 [vim.diagnostic.severity.INFO] = " ",
29 inlay_hints = { enabled = false, },
30 codelens = { enabled = false, },
31 document_highlight = { enabled = true, },
41 formatting_options = nil,
44 -- LSP Server Settings
45 ---@type lspconfig.options
50 workspace = { checkThirdParty = false, },
51 codeLens = { enable = true, },
52 completion = { callSnippet = "Replace", },
53 doc = { privateName = { "^_" }, },
58 paramName = "Disable",
59 semicolon = "Disable",
60 arrayIndex = "Disable",
63 disable = { "missing-fields", },
68 -- TODO: Add clangd extensions
69 -- https://github.com/p00f/clangd_extensions.nvim
71 -- you can do any additional lsp server setup here
72 -- return true if you don't want this server to be setup with lspconfig
73 ---@type table<string, fun(server:string, opts:_.lspconfig.options):boolean?>
75 -- example to setup with typescript.nvim
76 -- tsserver = function(_, opts)
77 -- require("typescript").setup({ server = opts })
80 -- Specify * to use this function as a fallback for any server
81 -- ["*"] = function(server, opts) end,
84 ---@param opts PluginLspOpts
85 config = function(_, opts)
86 local lspconfig = require('lspconfig')
87 for server, config in pairs(opts.servers) do
88 local capabilities = vim.tbl_deep_extend("force",
89 vim.lsp.protocol.make_client_capabilities() or {},
90 require('blink.cmp').get_lsp_capabilities() or {},
91 config.capabilities or {}
93 config.capabilities = capabilities
94 lspconfig[server].setup(config)
98 rmz.lsp.on_attach(function(client, buffer)
99 require("plugins.lsp.keymaps").on_attach(client, buffer)
103 rmz.lsp.on_dynamic_capability(require("plugins.lsp.keymaps").on_attach)
104 -- TODO: should vim.diagnostics be condigured directly?
105 vim.diagnostic.config(vim.deepcopy(opts.diagnostics))
107 -- get all the servers that are available through mason-lspconfig
108 local mlsp = require("mason-lspconfig")
109 -- TODO: use mason-lspconfig.get_available_servers()?
110 local all_mslp_servers = vim.tbl_keys(require("mason-lspconfig.mappings.server").lspconfig_to_package)
112 local ensure_installed = {} ---@type string[]
113 for server, server_opts in pairs(opts.servers) do
115 server_opts = server_opts == true and {} or server_opts
116 if server_opts.enabled ~= false then
117 -- run manual setup if mason=false or if this is a server that cannot be installed with mason-lspconfig
118 if server_opts.mason == false or not vim.tbl_contains(all_mslp_servers, server) then
119 require("lspconfig")[server].setup(server_opts)
121 ensure_installed[#ensure_installed + 1] = server
128 ensure_installed = vim.tbl_deep_extend(
131 rmz.lazy.opts("mason-lspconfig.nvim").ensure_installed or {}
133 handlers = { setup },
137 { "williamboman/mason.nvim",
139 keys = { { "<leader>cm", "<cmd>Mason<cr>", desc = "Mason" } },
140 build = ":MasonUpdate",
141 opts_extend = { "ensure_installed" },
148 ---@param opts MasonSettings | {ensure_installed: string[]}
149 config = function(_, opts)
150 require("mason").setup(opts)
151 local mr = require("mason-registry")
152 mr:on("package:install:success", function()
153 vim.defer_fn(function()
154 -- trigger FileType event to possibly load this newly installed LSP server
155 require("lazy.core.handler.event").trigger({
157 buf = vim.api.nvim_get_current_buf(),
162 mr.refresh(function()
163 for _, tool in ipairs(opts.ensure_installed) do
164 local p = mr.get_package(tool)
165 if not p:is_installed() then