Skip to content

Commit acdd701

Browse files
committed
feat: adjust mason v2
Based on PR nvim-lua#1475 : feat: add support for new LSP config API in Neovim 0.11+ link : nvim-lua#1475
1 parent 757fcfd commit acdd701

File tree

1 file changed

+15
-25
lines changed

1 file changed

+15
-25
lines changed

init.lua

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left wind
214214
vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
215215
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
216216
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
217+
217218
-- NOTE: Some terminals have colliding keymaps or are not able to send distinct keycodes
218219
-- vim.keymap.set("n", "<C-S-h>", "<C-w>H", { desc = "Move window to the left" })
219220
-- vim.keymap.set("n", "<C-S-l>", "<C-w>L", { desc = "Move window to the right" })
@@ -672,12 +673,6 @@ require('lazy').setup({
672673
},
673674
}
674675

675-
-- LSP servers and clients are able to communicate to each other what features they support.
676-
-- By default, Neovim doesn't support everything that is in the LSP specification.
677-
-- When you add blink.cmp, luasnip, etc. Neovim now has *more* capabilities.
678-
-- So, we create new capabilities with blink.cmp, and then broadcast that to the servers.
679-
local capabilities = require('blink.cmp').get_lsp_capabilities()
680-
681676
-- Enable the following language servers
682677
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
683678
--
@@ -718,6 +713,11 @@ require('lazy').setup({
718713
},
719714
},
720715
}
716+
---@type MasonLspconfigSettings
717+
---@diagnostic disable-next-line: missing-fields
718+
require('mason-lspconfig').setup {
719+
automatic_enable = vim.tbl_keys(servers or {}),
720+
}
721721

722722
-- Ensure the servers and tools above are installed
723723
--
@@ -738,19 +738,14 @@ require('lazy').setup({
738738
})
739739
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
740740

741-
require('mason-lspconfig').setup {
742-
ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer)
743-
automatic_installation = false,
744-
handlers = {
745-
function(server_name)
746-
local server = servers[server_name] or {}
747-
-- This handles overriding only values explicitly passed
748-
-- by the server configuration above. Useful when disabling
749-
-- certain features of an LSP (for example, turning off formatting for ts_ls)
750-
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
751-
end,
752-
},
753-
}
741+
-- Installed LSPs are configured and enabled automatically with mason-lspconfig
742+
-- The loop below is for overriding the default configuration of LSPs with the ones in the servers table
743+
for server_name, config in pairs(servers) do
744+
vim.lsp.config(server_name, config)
745+
end
746+
747+
-- NOTE: Some servers may require an old setup until they are updated. For the full list refer here: https://github.com/neovim/nvim-lspconfig/issues/3705
748+
-- These servers will have to be manually set up with require("lspconfig").server_name.setup{}
754749
end,
755750
},
756751

@@ -920,12 +915,7 @@ require('lazy').setup({
920915
},
921916

922917
-- Highlight todo, notes, etc in comments
923-
{
924-
'folke/todo-comments.nvim',
925-
event = 'VimEnter',
926-
dependencies = { 'nvim-lua/plenary.nvim' },
927-
opts = { signs = false, keywords = { TODO = { alt = { 'CSAH' } } } },
928-
},
918+
{ 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } },
929919

930920
{ -- Collection of various small independent plugins/modules
931921
'echasnovski/mini.nvim',

0 commit comments

Comments
 (0)