@@ -98,7 +98,8 @@ opts = function()
9898 timeout_ms = nil ,
9999 },
100100 -- LSP Server Settings
101- --- @type table<string , vim.lsp.Config |{ mason ?: boolean , enabled ?: boolean }| boolean>
101+ --- @alias lazyvim.lsp.Config vim.lsp.Config |{ mason ?: boolean , enabled ?: boolean }
102+ --- @type table<string , lazyvim.lsp.Config | boolean>
102103 servers = {
103104 lua_ls = {
104105 -- mason = false, -- set to false if you don't want this server to be installed with mason
223224 timeout_ms = nil ,
224225 },
225226 -- LSP Server Settings
226- --- @type table<string , vim.lsp.Config |{ mason ?: boolean , enabled ?: boolean }| boolean>
227+ --- @alias lazyvim.lsp.Config vim.lsp.Config |{ mason ?: boolean , enabled ?: boolean }
228+ --- @type table<string , lazyvim.lsp.Config | boolean>
227229 servers = {
228230 lua_ls = {
229231 -- mason = false, -- set to false if you don't want this server to be installed with mason
@@ -342,51 +344,36 @@ end
342344 and vim .tbl_keys (require (" mason-lspconfig.mappings" ).get_mason_map ().lspconfig_to_package )
343345 or {} --[[ @as string[] ]]
344346
345- local exclude_automatic_enable = {} --- @type string[]
346-
347+ --- @return boolean ? exclude automatic setup
347348 local function configure (server )
348- local server_opts = opts .servers [server ] or {}
349+ local sopts = opts .servers [server ]
350+ sopts = sopts == true and {} or (not sopts ) and { enabled = false } or sopts --[[ @as lazyvim.lsp.Config]]
351+ if sopts .enabled == false then
352+ return true
353+ end
349354
350355 local setup = opts .setup [server ] or opts .setup [" *" ]
351- if setup and setup (server , server_opts ) then
352- return true -- lsp will be setup by the setup function
356+ if setup and setup (server , sopts ) then
357+ return true -- lsp will be configured and enabled by the setup function
353358 end
354359
355- vim .lsp .config (server , server_opts )
360+ vim .lsp .config (server , sopts ) -- configure the server
356361
357362 -- manually enable if mason=false or if this is a server that cannot be installed with mason-lspconfig
358- if server_opts .mason == false or not vim .tbl_contains (mason_all , server ) then
363+ if sopts .mason == false or not vim .tbl_contains (mason_all , server ) then
359364 vim .lsp .enable (server )
360365 return true
361366 end
362- return false
363- end
364-
365- local ensure_installed = {} --- @type string[]
366- for server , server_opts in pairs (opts .servers ) do
367- server_opts = server_opts == true and {} or server_opts or false
368- if server_opts and server_opts .enabled ~= false then
369- -- run manual setup if mason=false or if this is a server that cannot be installed with mason-lspconfig
370- if configure (server ) then
371- exclude_automatic_enable [# exclude_automatic_enable + 1 ] = server
372- else
373- ensure_installed [# ensure_installed + 1 ] = server
374- end
375- else
376- exclude_automatic_enable [# exclude_automatic_enable + 1 ] = server
377- end
378367 end
379368
369+ local servers = vim .tbl_keys (opts .servers )
370+ local exclude = vim .tbl_filter (configure , servers )
380371 if have_mason then
381372 require (" mason-lspconfig" ).setup ({
382- ensure_installed = vim .tbl_deep_extend (
383- " force" ,
384- ensure_installed ,
385- LazyVim .opts (" mason-lspconfig.nvim" ).ensure_installed or {}
386- ),
387- automatic_enable = {
388- exclude = exclude_automatic_enable ,
389- },
373+ ensure_installed = vim .tbl_filter (function (server )
374+ return not vim .tbl_contains (exclude , server )
375+ end , vim .list_extend (servers , LazyVim .opts (" mason-lspconfig.nvim" ).ensure_installed or {})),
376+ automatic_enable = { exclude = exclude },
390377 })
391378 end
392379 end ),
0 commit comments