mirror of
https://github.com/tomru/nvim.git
synced 2026-03-03 06:27:14 +01:00
update lsp config for mason 2.0
This commit is contained in:
@@ -7,8 +7,8 @@ return {
|
|||||||
-- Automatically install LSPs and related tools to stdpath for Neovim
|
-- Automatically install LSPs and related tools to stdpath for Neovim
|
||||||
-- Mason must be loaded before its dependents so we need to set it up here.
|
-- Mason must be loaded before its dependents so we need to set it up here.
|
||||||
-- NOTE: `opts = {}` is the same as calling `require('mason').setup({})`
|
-- NOTE: `opts = {}` is the same as calling `require('mason').setup({})`
|
||||||
{ 'williamboman/mason.nvim', opts = {} },
|
{ 'mason-org/mason.nvim', opts = {} },
|
||||||
'williamboman/mason-lspconfig.nvim',
|
'mason-org/mason-lspconfig.nvim',
|
||||||
'WhoIsSethDaniel/mason-tool-installer.nvim',
|
'WhoIsSethDaniel/mason-tool-installer.nvim',
|
||||||
|
|
||||||
-- Useful status updates for LSP.
|
-- Useful status updates for LSP.
|
||||||
@@ -144,9 +144,7 @@ return {
|
|||||||
--
|
--
|
||||||
-- This may be unwanted, since they displace some of your code
|
-- This may be unwanted, since they displace some of your code
|
||||||
if client and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_inlayHint, event.buf) then
|
if client and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_inlayHint, event.buf) then
|
||||||
map('<leader>th', function()
|
map('<leader>th', function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) end, '[T]oggle Inlay [H]ints')
|
||||||
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf })
|
|
||||||
end, '[T]oggle Inlay [H]ints')
|
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
@@ -180,12 +178,6 @@ return {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
-- LSP servers and clients are able to communicate to each other what features they support.
|
|
||||||
-- By default, Neovim doesn't support everything that is in the LSP specification.
|
|
||||||
-- When you add blink.cmp, luasnip, etc. Neovim now has *more* capabilities.
|
|
||||||
-- So, we create new capabilities with blink.cmp, and then broadcast that to the servers.
|
|
||||||
local capabilities = require('blink.cmp').get_lsp_capabilities()
|
|
||||||
|
|
||||||
-- 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.
|
||||||
--
|
--
|
||||||
@@ -235,6 +227,12 @@ return {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
---@type MasonLspconfigSettings
|
||||||
|
---@diagnostic disable-next-line: missing-fields
|
||||||
|
require('mason-lspconfig').setup {
|
||||||
|
automatic_enable = vim.tbl_keys(servers or {}),
|
||||||
|
}
|
||||||
|
|
||||||
-- Ensure the servers and tools above are installed
|
-- Ensure the servers and tools above are installed
|
||||||
--
|
--
|
||||||
-- To check the current status of installed tools and/or manually install
|
-- To check the current status of installed tools and/or manually install
|
||||||
@@ -254,20 +252,14 @@ return {
|
|||||||
})
|
})
|
||||||
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
|
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
|
||||||
|
|
||||||
require('mason-lspconfig').setup {
|
-- Installed LSPs are configured and enabled automatically with mason-lspconfig
|
||||||
ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer)
|
-- The loop below is for overriding the default configuration of LSPs with the ones in the servers table
|
||||||
automatic_installation = false,
|
for server_name, config in pairs(servers) do
|
||||||
handlers = {
|
vim.lsp.config(server_name, config)
|
||||||
function(server_name)
|
end
|
||||||
local server = servers[server_name] or {}
|
|
||||||
-- This handles overriding only values explicitly passed
|
-- 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
|
||||||
-- by the server configuration above. Useful when disabling
|
-- These servers will have to be manually set up with require("lspconfig").server_name.setup{}
|
||||||
-- certain features of an LSP (for example, turning off formatting for ts_ls)
|
|
||||||
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
|
|
||||||
require('lspconfig')[server_name].setup(server)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user