nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Bug] An auto-discovered LSP server takes over the languages of a server configured in lspServers

Open addyCooks opened this issue 1 week ago • 1 comments

Description

Configured LSP servers should win for the languages they declare. Discovery adds any server that has at least one new language, then starts it with all of its languages and registers them all, so the discovered server replaces the configured one for the shared languages.

Environment

  • OS: Windows 11 Home 10.0.26300
  • Node version: v22.22.3
  • Nanocoder version: 1.32.0 (built from main at eb7dee57)
  • Provider: Not provider-specific
  • Model: Not model-specific

Steps to Reproduce

  1. Put a working typescript-language-server (or a .cmd shim) in the project's node_modules/.bin.
  2. Call manager.initialize({servers: [{name: 'my-custom-ts', command: <a working LSP server>, args: ['--stdio'], languages: ['ts']}]}) with auto-discovery on (the default).
  3. Read manager.getStatus().

Expected Behavior

my-custom-ts keeps languages: ["ts"]. The discovered server only gets the languages that are not claimed.

Actual Behavior

The custom server is listed with no languages and ts belongs to the discovered server.

Logs/Screenshots

{"name":"my-custom-ts","ready":true,"languages":[]},
{"name":"typescript-language-server","ready":true,"languages":["ts","tsx","js","jsx","mjs",...]}

Additional Context

  • [x] I have searched existing issues to ensure this is not a duplicate
  • [x] I can reproduce this issue consistently
  • [x] This issue occurs with the latest version of nanocoder (main)

Suggested fix:

  • source/lsp/lsp-manager.ts:138-160 (initialize): when a discovered server has some covered languages, start it with languages filtered to the uncovered ones.
  • source/lsp/lsp-manager.ts:227 (languageToServer.set) overwrites the existing mapping. Use if (!this.languageToServer.has(lang)).
  • Add a test with a custom server for ts and a discovered server for ts, tsx, js.

addyCooks avatar Nov 23 '26 07:11 addyCooks

I'd like to pick this up. I reproduced it with a configured ts server and a discovered typescript-language-server (the configured one ended with languages: []). The fix limits each discovered server to the languages no earlier server claims and skips it if none are left, with unit tests. Could you assign me? I'll open the PR then.

seragAhmed avatar Nov 23 '26 09:11 seragAhmed