Skip to content

Commit 86dbd56

Browse files
committed
Fix setting up mason.nvim and mason-lspconfig.nvim
These are currently being set up twice: - mason.nvim once by lazy.nvim (`config = true`) and then once manually - mason-lspconfig.nvim twice manually
1 parent 7af594f commit 86dbd56

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

init.lua

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ require('lazy').setup({
8383
'neovim/nvim-lspconfig',
8484
dependencies = {
8585
-- Automatically install LSPs to stdpath for neovim
86-
{ 'williamboman/mason.nvim', config = true },
86+
'williamboman/mason.nvim',
8787
'williamboman/mason-lspconfig.nvim',
8888

8989
-- Useful status updates for LSP
@@ -507,6 +507,10 @@ vim.defer_fn(function()
507507
}
508508
end, 0)
509509

510+
-- [[ Configure Mason ]]
511+
-- See `:help mason.nvim`
512+
require('mason').setup()
513+
510514
-- [[ Configure LSP ]]
511515
-- This function gets run when an LSP connects to a particular buffer.
512516
local on_attach = function(_, bufnr)
@@ -572,11 +576,6 @@ require('which-key').register({
572576
['<leader>h'] = { 'Git [H]unk' },
573577
}, { mode = 'v' })
574578

575-
-- mason-lspconfig requires that these setup functions are called in this order
576-
-- before setting up the servers.
577-
require('mason').setup()
578-
require('mason-lspconfig').setup()
579-
580579
-- Enable the following language servers
581580
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
582581
--
@@ -610,22 +609,21 @@ require('neodev').setup()
610609
local capabilities = vim.lsp.protocol.make_client_capabilities()
611610
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
612611

613-
-- Ensure the servers above are installed
614-
local mason_lspconfig = require 'mason-lspconfig'
615-
616-
mason_lspconfig.setup {
612+
require('mason-lspconfig').setup {
613+
-- Ensure the servers above are installed
617614
ensure_installed = vim.tbl_keys(servers),
618-
}
619-
620-
mason_lspconfig.setup_handlers {
621-
function(server_name)
622-
require('lspconfig')[server_name].setup {
623-
capabilities = capabilities,
624-
on_attach = on_attach,
625-
settings = servers[server_name],
626-
filetypes = (servers[server_name] or {}).filetypes,
627-
}
628-
end,
615+
-- Automatic setup of installed servers
616+
-- See `:help mason-lspconfig-automatic-server-setup`
617+
handlers = {
618+
function(server_name)
619+
require('lspconfig')[server_name].setup {
620+
capabilities = capabilities,
621+
on_attach = on_attach,
622+
settings = servers[server_name],
623+
filetypes = (servers[server_name] or {}).filetypes,
624+
}
625+
end,
626+
},
629627
}
630628

631629
-- [[ Configure nvim-cmp ]]

0 commit comments

Comments
 (0)