Skip to content

Conversation

@AsPulse
Copy link

@AsPulse AsPulse commented Nov 21, 2025

Problem

Currently, non-Deno TypeScript LSPs (ts_ls, tsgo, vtsls) have mechanisms to prevent conflicts by not activating on_dir when a Deno project is detected.

root_dir = function(bufnr, on_dir)
-- The project root is where the LSP can be started from
-- As stated in the documentation above, this LSP supports monorepos and simple projects.
-- We select then from the project root, which is identified by the presence of a package
-- manager lock file.
local root_markers = { 'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'bun.lockb', 'bun.lock' }
-- Give the root markers equal priority by wrapping them in a table
root_markers = vim.fn.has('nvim-0.11.3') == 1 and { root_markers, { '.git' } }
or vim.list_extend(root_markers, { '.git' })
-- exclude deno
local deno_path = vim.fs.root(bufnr, { 'deno.json', 'deno.jsonc', 'deno.lock' })
local project_root = vim.fs.root(bufnr, root_markers)
if deno_path and (not project_root or #deno_path >= #project_root) then
return
end
-- We fallback to the current working directory if no project root is found
on_dir(project_root or vim.fn.getcwd())
end,

However, denols lacks such a mechanism. As a result, when a non-Deno project is opened with denols enabled, both LSPs become attached.

Solution

We will add conflict prevention logic to denols, similar to what non-Deno TypeScript LSPs have.
Currently, Deno has a workspace feature, so we will detect the workspace root using deno.lock in the same way non-Deno TypeScript LSPs do. If deno.lock is not present and only deno.json(c) exists, we will handle it with a fallback.


Testing

I confirmed that the expected LSP launched with the expected root_dir in the following situations:

  • Deno monorepo project
  • A single Deno project with a deno.lock file in the root
  • A single Deno project without a deno.lock file in the root
  • npm monorepo project
  • A single npm project with a package-lock.json file in the root
  • A single npm project without a package-lock.json (or any other non-Deno lock file) in the root

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant