[Bug] An auto-discovered LSP server takes over the languages of a server configured in lspServers
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
- Put a working
typescript-language-server(or a.cmdshim) in the project'snode_modules/.bin. - Call
manager.initialize({servers: [{name: 'my-custom-ts', command: <a working LSP server>, args: ['--stdio'], languages: ['ts']}]})with auto-discovery on (the default). - 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 withlanguagesfiltered to the uncovered ones.source/lsp/lsp-manager.ts:227(languageToServer.set) overwrites the existing mapping. Useif (!this.languageToServer.has(lang)).- Add a test with a custom server for
tsand a discovered server forts,tsx,js.
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.