fix(lsp): properly ambiguate denols vs vtsls

This commit is contained in:
Folke Lemaitre
2025-09-15 21:00:19 +02:00
parent 271fecb067
commit 2f75d9a90f

View File

@@ -230,20 +230,24 @@ return {
if vim.lsp.is_enabled("denols") and vim.lsp.is_enabled("vtsls") then
---@param server string
---@param markers string[]
local resolve = function(server, markers)
local resolve = function(server)
local markers, root_dir = vim.lsp.config[server].root_markers, vim.lsp.config[server].root_dir
vim.lsp.config(server, {
root_dir = function(bufnr, on_dir)
local is_deno = vim.fs.root(bufnr, { "deno.json", "deno.jsonc" }) ~= nil
if is_deno == (server == "denols") then
local root = vim.fs.root(bufnr, markers)
return root and on_dir(root)
if root_dir then
return root_dir(bufnr, on_dir)
elseif type(markers) == "table" then
local root = vim.fs.root(bufnr, markers)
return root and on_dir(root)
end
end
end,
})
end
resolve("denols", vim.lsp.config.denols.root_markers)
resolve("vtsls", vim.lsp.config.vtsls.root_markers)
resolve("denols")
resolve("vtsls")
end
end,
},