Skip to content

Commit df1f86a

Browse files
misumisumimisumisumi
andauthored
refactor(mason): support for mason and mason-lspconfig v2 (#1466)
- fix #1461 Co-authored-by: misumisumi <sumiharu@misumi-sumi.com>
1 parent 8b1476d commit df1f86a

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

lua/modules/configs/completion/mason-lspconfig.lua

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ local M = {}
33
M.setup = function()
44
local diagnostics_virtual_lines = require("core.settings").diagnostics_virtual_lines
55
local diagnostics_level = require("core.settings").diagnostics_level
6+
local lsp_deps = require("core.settings").lsp_deps
67

7-
local nvim_lsp = require("lspconfig")
8-
local mason_lspconfig = require("mason-lspconfig")
98
require("lspconfig.ui.windows").default_options.border = "rounded"
10-
119
require("modules.utils").load_plugin("mason-lspconfig", {
12-
ensure_installed = require("core.settings").lsp_deps,
10+
ensure_installed = lsp_deps,
1311
})
1412

1513
vim.diagnostic.config({
@@ -61,22 +59,25 @@ please REMOVE your LSP configuration (rust_analyzer.lua) from the `servers` dire
6159

6260
if not ok then
6361
-- Default to use factory config for server(s) that doesn't include a spec
64-
nvim_lsp[lsp_name].setup(opts)
65-
return
62+
vim.lsp.config(lsp_name, opts)
63+
vim.lsp.enable(lsp_name)
6664
elseif type(custom_handler) == "function" then
6765
--- Case where language server requires its own setup
6866
--- Make sure to call require("lspconfig")[lsp_name].setup() in the function
6967
--- See `clangd.lua` for example.
7068
custom_handler(opts)
69+
vim.lsp.enable(lsp_name)
7170
elseif type(custom_handler) == "table" then
72-
nvim_lsp[lsp_name].setup(
71+
vim.lsp.config(
72+
lsp_name,
7373
vim.tbl_deep_extend(
7474
"force",
7575
opts,
7676
type(default_handler) == "table" and default_handler or {},
7777
custom_handler
7878
)
7979
)
80+
vim.lsp.enable(lsp_name)
8081
else
8182
vim.notify(
8283
string.format(
@@ -88,9 +89,12 @@ please REMOVE your LSP configuration (rust_analyzer.lua) from the `servers` dire
8889
{ title = "nvim-lspconfig" }
8990
)
9091
end
92+
return
9193
end
9294

93-
mason_lspconfig.setup_handlers({ mason_lsp_handler })
95+
for _, lsp in ipairs(lsp_deps) do
96+
mason_lsp_handler(lsp)
97+
end
9498
end
9599

96100
return M

lua/modules/plugins/completion.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ completion["neovim/nvim-lspconfig"] = {
66
event = { "CursorHold", "CursorHoldI" },
77
config = require("completion.lsp"),
88
dependencies = {
9-
{ "williamboman/mason.nvim", version = "1.11.0" },
10-
{ "williamboman/mason-lspconfig.nvim", version = "1.32.0" },
9+
{ "mason-org/mason.nvim" },
10+
{ "mason-org/mason-lspconfig.nvim" },
1111
{ "folke/neoconf.nvim" },
1212
{
1313
"Jint-lzxy/lsp_signature.nvim",

0 commit comments

Comments
 (0)