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