fix(vtsls): fix and move denols/vtsls disambigutaion to typescript extra. Fixes #6476

This commit is contained in:
Folke Lemaitre
2025-09-21 11:58:57 +02:00
parent 89ce0438d6
commit 775621ac0a
2 changed files with 22 additions and 22 deletions

View File

@@ -131,6 +131,28 @@ return {
return true
end,
vtsls = function(_, opts)
if vim.lsp.config.denols and vim.lsp.config.vtsls then
---@param server string
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
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")
resolve("vtsls")
end
LazyVim.lsp.on_attach(function(client, buffer)
client.commands["_typescript.moveToFileRefactoring"] = function(command, ctx)
---@type string, string, lsp.Range

View File

@@ -234,28 +234,6 @@ return {
},
})
end
if vim.lsp.is_enabled and vim.lsp.is_enabled("denols") and vim.lsp.is_enabled("vtsls") then
---@param server string
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
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")
resolve("vtsls")
end
end),
},