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:
parent
7af594fd31
commit
86dbd56d31
40
init.lua
40
init.lua
|
@ -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,22 +609,21 @@ require('neodev').setup()
|
|||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
|
||||
|
||||
-- Ensure the servers above are installed
|
||||
local mason_lspconfig = require 'mason-lspconfig'
|
||||
|
||||
mason_lspconfig.setup {
|
||||
require('mason-lspconfig').setup {
|
||||
-- Ensure the servers above are installed
|
||||
ensure_installed = vim.tbl_keys(servers),
|
||||
}
|
||||
|
||||
mason_lspconfig.setup_handlers {
|
||||
function(server_name)
|
||||
require('lspconfig')[server_name].setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
settings = servers[server_name],
|
||||
filetypes = (servers[server_name] or {}).filetypes,
|
||||
}
|
||||
end,
|
||||
-- Automatic setup of installed servers
|
||||
-- See `:help mason-lspconfig-automatic-server-setup`
|
||||
handlers = {
|
||||
function(server_name)
|
||||
require('lspconfig')[server_name].setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
settings = servers[server_name],
|
||||
filetypes = (servers[server_name] or {}).filetypes,
|
||||
}
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
-- [[ Configure nvim-cmp ]]
|
||||
|
|
Loading…
Reference in New Issue