Skip to content

fix(editor): deno runtime detection - #3111

Merged
sinelaw merged 2 commits into
sinelaw:masterfrom
atk:fix/editor/deno-runtime-detection
Sep 3, 2026
Merged

sinelaw merged 2 commits into
sinelaw:masterfrom
atk:fix/editor/deno-runtime-detection

Conversation

@atk

@atk atk commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Fixes #2981

After rummaging through the code, I realized that any deno.json(c) in the project would cause fresh to switch LSP to deno whether a runtime was available or not. This code checks if a runtime is in path and only then makes the switch.

sinelaw commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Heads up so this isn't duplicated work: #3159 includes the runtime check from this PR, built on @atk's diagnosis in #2981 (the deno.json(c) detection in configure_lsp_servers).

Two differences from the version here:

  • The probe goes through LspManager::command_exists_via_authority — the same authority-routed check the LSP status popup makes — rather than walking PATH directly, so a container or SSH authority is asked about its own PATH instead of the host's, and nothing branches on backend kind.
  • It also fixes the messages, which named the wrong binary: the status bar said TypeScript LSP server 'typescript-language-server' not found and the dialog offered npm install -g typescript-language-server for what was really a missing deno — the reason "I did not find deno anywhere in the configuration" was such a reasonable thing to conclude.

@atk, the decision on how to land this is the maintainer's, not mine: #3159 can be rebased onto your commit if you'd prefer the authorship to sit here, or this PR closed in favour of it. Either is fine by me — thanks for tracking the cause down.


Generated by Claude Code

@sinelaw

sinelaw commented Sep 3, 2026

Copy link
Copy Markdown
Owner

I'll merge this one and add a follow-up to move this all out of the rust core and into a plugin

@sinelaw
sinelaw force-pushed the fix/editor/deno-runtime-detection branch from d61a928 to 13d3362 Compare September 3, 2026 06:00
@sinelaw
sinelaw force-pushed the fix/editor/deno-runtime-detection branch from 13d3362 to 8a7602d Compare September 3, 2026 06:02
sinelaw pushed a commit that referenced this pull request Sep 3, 2026
#2981 is being taken by #3111 and then reworked so the detection is not
hard-coded in the editor core at all, so it does not belong here. This
removes the whole #2981 half: the `deno_lsp_override` extraction and its
bounded authority probe, the `command_exists_via_authority_within` helper
that existed only for it, the `server_command` on `AsyncMessage::LspError`
and the install-help changes in `lsp_help.ts` that go with it, plus the
changelog entry and the unit tests for the detection.

`configure_lsp_servers` is back to master's version verbatim.

What remains is #2197 (LSP request timeouts stop being silent) and #722
(inlay hints stop drifting on an edit at their anchor).

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SHsuKyMdSZ7soeFzDziRNw
@sinelaw
sinelaw merged commit d9ef3a8 into sinelaw:master Sep 3, 2026
11 checks passed
@sinelaw

sinelaw commented Sep 3, 2026

Copy link
Copy Markdown
Owner

🙏

sinelaw pushed a commit that referenced this pull request Sep 3, 2026
#3111 landed as a squash, so the two commits this branch carried from it
no longer match master's history. The Deno block master reintroduces is
the one this branch moves into `plugins/deno_lsp.ts`; the runtime check
it added is preserved there.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SHsuKyMdSZ7soeFzDziRNw
sinelaw pushed a commit that referenced this pull request Sep 3, 2026
`std::env` and `Path` came back with the merge of #3111; nothing in
`window/mod.rs` uses them now that the detection lives in the plugin.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SHsuKyMdSZ7soeFzDziRNw
sinelaw pushed a commit that referenced this pull request Sep 3, 2026
#3111 (now on master) added the runtime check this keeps. What changes
here is where the convention lives.

`configure_lsp_servers` hard-coded one project convention — a root with a
`deno.json` or `deno.jsonc` is served by `deno lsp` — into window
construction. That is a claim about projects, not about the editor: it
cannot be turned off, inspected or replaced without a rebuild, every
further convention costs another branch in the same function, and the
check had to be written twice (marker file, then runtime) inside code
whose job is wiring a manager.

It is now `plugins/deno_lsp.ts`, which:

* switches JavaScript and TypeScript to `deno lsp` when the active
  window's root has a `deno.json`/`deno.jsonc` **and** `deno` is on PATH,
* puts back what was configured before when a window without one becomes
  active — captured from the live config before the first override, so
  the user's own entry comes back rather than a guess at it,
* caches its decision per root, so re-evaluating on window and buffer
  changes costs nothing.

`configure_lsp_servers` loses the block, its `root` parameter (nothing
else used it) and the `Path`/`env` imports that came with #3111's check.

Two differences from the core version, both noted in the plugin:
`registerLspServer` applies to the active window and the runtime config
rather than per window root, which is why the choice is re-evaluated when
the active window changes; and the choice lands when the plugin loads, so
a server already spawned keeps its command until restarted — in the
default configuration JS/TS are `auto_start: false`, so nothing has
started that early.

Tests drive the real plugin through the harness: a Deno project with the
runtime installed switches (and JavaScript switches with TypeScript), a
Deno project without it keeps the configured server (#2981), and a
project with no marker file is untouched. They pin the process globals,
since `PATH` is one and these run as threads of one binary.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SHsuKyMdSZ7soeFzDziRNw
sinelaw pushed a commit that referenced this pull request Sep 3, 2026
`configure_lsp_servers` hard-coded one project convention — a root with a
`deno.json` or `deno.jsonc` is served by `deno lsp` — into window
construction. That is a claim about projects, not about the editor: it
cannot be turned off, inspected or replaced without a rebuild, and every
further convention costs another branch in code whose job is wiring a
manager. #3111 had to add its runtime check inside that same block.

It is now `plugins/deno_lsp.ts`, which switches JavaScript and TypeScript
to `deno lsp` when the active window's root has the marker file and `deno`
is on PATH, puts back what was configured before when a window without one
becomes active, and caches its decision per root. `configure_lsp_servers`
loses the block, its `root` parameter and the `Path`/`env` imports.

Two differences from the core version, both noted in the plugin: the
choice follows the active window rather than being fixed per window root,
and it lands when the plugin loads, so an already-spawned server keeps its
command until restarted (JS/TS are `auto_start: false` by default).

Tests drive the real plugin through the harness: a Deno project with the
runtime installed switches (and JavaScript switches with TypeScript), a
Deno project without it keeps the configured server (#2981), and a project
with no marker file is untouched. They pin the process globals, since
`PATH` is one and these run as threads of one binary.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SHsuKyMdSZ7soeFzDziRNw
sinelaw pushed a commit that referenced this pull request Sep 3, 2026
`configure_lsp_servers` hard-coded one project convention — a root with a
`deno.json` or `deno.jsonc` is served by `deno lsp` — into window
construction. That is a claim about projects, not about the editor: it
cannot be turned off, inspected or replaced without a rebuild, and every
further convention costs another branch in code whose job is wiring a
manager. #3111 had to add its runtime check inside that same block.

It is now `plugins/deno_lsp.ts`, which switches JavaScript and TypeScript
to `deno lsp` when the active window's root has the marker file and `deno`
is on PATH, puts back what was configured before when a window without one
becomes active, and caches its decision per root. `configure_lsp_servers`
loses the block, its `root` parameter and the `Path`/`env` imports.

A language the user turned off is left alone in both directions: the
"Disable" rows persist `enabled: false`, and `registerLspServer` can only
register an enabled server, so touching such a language would turn it
back on. The core version replaced the entry regardless.

Two differences from the core version, both noted in the plugin: the
choice follows the active window rather than being fixed per window root,
and it lands when the plugin loads, so an already-spawned server keeps its
command until restarted (JS/TS are `auto_start: false` by default).

Tests drive the real plugin through the harness: a Deno project with the
runtime installed switches both languages, one without it keeps the
configured server (#2981), a project with no marker file is untouched, a
disabled language is neither switched nor re-enabled, and leaving a Deno
project for a plain one restores the configured server. They pin the
process globals, since `PATH` is one and these run as threads of one
binary.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SHsuKyMdSZ7soeFzDziRNw
sinelaw added a commit that referenced this pull request Sep 3, 2026
)

`configure_lsp_servers` hard-coded one project convention — a root with a
`deno.json` or `deno.jsonc` is served by `deno lsp` — into window
construction. That is a claim about projects, not about the editor: it
cannot be turned off, inspected or replaced without a rebuild, and every
further convention costs another branch in code whose job is wiring a
manager. #3111 had to add its runtime check inside that same block.

It is now `plugins/deno_lsp.ts`, which switches JavaScript and TypeScript
to `deno lsp` when the active window's root has the marker file and `deno`
is on PATH, puts back what was configured before when a window without one
becomes active, and caches its decision per root. `configure_lsp_servers`
loses the block, its `root` parameter and the `Path`/`env` imports.

A language the user turned off is left alone in both directions: the
"Disable" rows persist `enabled: false`, and `registerLspServer` can only
register an enabled server, so touching such a language would turn it
back on. The core version replaced the entry regardless.

Two differences from the core version, both noted in the plugin: the
choice follows the active window rather than being fixed per window root,
and it lands when the plugin loads, so an already-spawned server keeps its
command until restarted (JS/TS are `auto_start: false` by default).

Tests drive the real plugin through the harness: a Deno project with the
runtime installed switches both languages, one without it keeps the
configured server (#2981), a project with no marker file is untouched, a
disabled language is neither switched nor re-enabled, and leaving a Deno
project for a plain one restores the configured server. They pin the
process globals, since `PATH` is one and these run as threads of one
binary.


Claude-Session: https://claude.ai/code/session_01SHsuKyMdSZ7soeFzDziRNw

Co-authored-by: Claude <[email protected]>
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.

bug: LSP is switched to deno when a deno.json(c) is found whether deno is available or not

2 participants