Skip to content

Commit 7701661

Browse files
committed
fix(vtsls): apply the same deno-excluding logic that ts_ls uses
1 parent 0cb3180 commit 7701661

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

lsp/vtsls.lua

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@
6464
--- This works without the need of spawning multiple instances of `vtsls`, saving memory.
6565
---
6666
--- It is recommended to use the same version of TypeScript in all packages, and therefore have it available in your workspace root. The location of the TypeScript binary will be determined automatically, but only once.
67+
---
68+
--- This includes the same Deno-excluding logic from `ts_ls`. It is not recommended to enable both `vtsls` and `ts_ls` at the same time!
6769

6870
---@type vim.lsp.Config
6971
return {
@@ -88,15 +90,20 @@ return {
8890
-- Give the root markers equal priority by wrapping them in a table
8991
root_markers = vim.fn.has('nvim-0.11.3') == 1 and { root_markers, { '.git' } }
9092
or vim.list_extend(root_markers, { '.git' })
91-
9293
-- exclude deno
93-
if vim.fs.root(bufnr, { 'deno.json', 'deno.jsonc', 'deno.lock' }) then
94+
local deno_root = vim.fs.root(bufnr, { 'deno.json', 'deno.jsonc' })
95+
local deno_lock_root = vim.fs.root(bufnr, { 'deno.lock' })
96+
local project_root = vim.fs.root(bufnr, root_markers)
97+
if deno_lock_root and (not project_root or #deno_lock_root > #project_root) then
98+
-- deno lock is closer than package manager lock, abort
9499
return
95100
end
96-
101+
if deno_root and (not project_root or #deno_root >= #project_root) then
102+
-- deno config is closer than or equal to package manager lock, abort
103+
return
104+
end
105+
-- project is standard TS, not deno
97106
-- We fallback to the current working directory if no project root is found
98-
local project_root = vim.fs.root(bufnr, root_markers) or vim.fn.getcwd()
99-
100-
on_dir(project_root)
107+
on_dir(project_root or vim.fn.getcwd())
101108
end,
102109
}

0 commit comments

Comments
 (0)