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
This commit is contained in:
William Boman 2024-02-21 00:08:21 +01:00
parent 7af594fd31
commit 86dbd56d31
1 changed files with 19 additions and 21 deletions

View File

@ -83,7 +83,7 @@ require('lazy').setup({
'neovim/nvim-lspconfig',
dependencies = {
-- Automatically install LSPs to stdpath for neovim
{ 'williamboman/mason.nvim', config = true },
'williamboman/mason.nvim',
'williamboman/mason-lspconfig.nvim',
-- Useful status updates for LSP
@ -507,6 +507,10 @@ vim.defer_fn(function()
}
end, 0)
-- [[ Configure Mason ]]
-- See `:help mason.nvim`
require('mason').setup()
-- [[ Configure LSP ]]
-- This function gets run when an LSP connects to a particular buffer.
local on_attach = function(_, bufnr)
@ -572,11 +576,6 @@ require('which-key').register({
['<leader>h'] = { 'Git [H]unk' },
}, { mode = 'v' })
-- mason-lspconfig requires that these setup functions are called in this order
-- before setting up the servers.
require('mason').setup()
require('mason-lspconfig').setup()
-- Enable the following language servers
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
--
@ -610,14 +609,12 @@ require('neodev').setup()
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
require('mason-lspconfig').setup {
-- Ensure the servers above are installed
local mason_lspconfig = require 'mason-lspconfig'
mason_lspconfig.setup {
ensure_installed = vim.tbl_keys(servers),
}
mason_lspconfig.setup_handlers {
-- Automatic setup of installed servers
-- See `:help mason-lspconfig-automatic-server-setup`
handlers = {
function(server_name)
require('lspconfig')[server_name].setup {
capabilities = capabilities,
@ -626,6 +623,7 @@ mason_lspconfig.setup_handlers {
filetypes = (servers[server_name] or {}).filetypes,
}
end,
},
}
-- [[ Configure nvim-cmp ]]