-
-
Notifications
You must be signed in to change notification settings - Fork 272
fix(lsp): improve isServerInstalled for custom server configs #282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(lsp): improve isServerInstalled for custom server configs #282
Conversation
Ahoy mateys! Some landlubber LSP servers were hidin' from detection! π΄ββ οΈ The Problem (ships lost at sea): - Custom LSP servers configured in oh-my-opencode.json weren't detected - Both absolute paths AND runtime wrappers failed The Fix (better treasure-findin' skills): 1. Absolute path support (for direct executables): ["C:\Users\me\go\bin\gopls.exe"] ["C:\Users\me\.bun\bin\typescript-language-server.exe", "--stdio"] -> If cmd contains / or \, verify via existsSync() 2. Runtime wrapper support (for JS-based servers): ["node", "C:\path\to\server.js", "--stdio"] ["bun", "run", "my-lsp-server"] -> bun/node are always aboard the oh-my-opencode ship Real world configs that now work: - go: ["C:\Users\user\go\bin\gopls.exe"] - civet: ["node", "...\server.js", "--stdio"] - svelte: ["node", "...\server.js", "--stdio"] - typescript: ["C:\...\typescript-language-server.exe", "--stdio"] These scallywags can now be properly detected! π¦
Greptile Summaryimproved LSP server detection to support custom configurations with absolute paths and runtime wrappers (
Issue found: absolute path logic should return Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Config as oh-my-opencode.json
participant FSE as findServerForExtension()
participant ISI as isServerInstalled()
participant FS as File System
User->>Config: Configure custom LSP server<br/>{command: ["node", "path/to/server.js"]}
User->>FSE: Open .ts file
FSE->>Config: Load merged servers
Config-->>FSE: Return server configs
FSE->>ISI: Check if server installed<br/>command[0] = "node"
alt Command is runtime wrapper (node/bun)
ISI->>ISI: Check if cmd === "node" || "bun"
ISI-->>FSE: Return true (always available)
else Command is absolute path
ISI->>ISI: Check if cmd includes "/" or "\"
ISI->>FS: existsSync(absolutePath)
FS-->>ISI: true/false
ISI-->>FSE: Return result
else Command is in PATH
ISI->>FS: Check PATH directories
FS-->>ISI: Found/Not found
ISI-->>FSE: Return result
end
FSE-->>User: LSP server activated β
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional Comments (1)
-
src/tools/lsp/config.ts, line 151-154 (link)logic: if the absolute path doesn't exist, should immediately return
falseinstead of falling through to PATH checks (which won't make sense for absolute paths anyway)
1 file reviewed, 1 comment
|
@sisyphus-dev-ai review this |
|
π Hey @code-yeongyu! I'm on it... |
sisyphus-dev-ai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review: APPROVED β
Good fix for a real-world problem. The changes are minimal, focused, and well-documented.
What This Fixes
Custom LSP servers configured in oh-my-opencode.json weren't being detected as "installed" because isServerInstalled() only checked:
- PATH directories
- Some hardcoded directories (
node_modules/.bin,~/.config/opencode/bin)
This missed:
- Absolute paths:
["C:\Users\...\gopls.exe"] - Runtime wrappers:
["node", "path/to/server.js", "--stdio"]
Code Analysis
Absolute Path Detection (good):
if (cmd.includes("/") || cmd.includes("\\")) {
if (existsSync(cmd)) return true
}- Correctly handles both Unix (
/) and Windows (\) path separators - Falls through to PATH check if file doesn't exist (no false negatives)
- Placed early for performance (avoids unnecessary PATH iteration)
Runtime Wrapper Detection (good):
if (cmd === "bun" || cmd === "node") {
return true
}- Pragmatic assumption: if you're running oh-my-opencode, you have bun/node
- Handles the common case of JS-based LSP servers
Minor Notes (Non-blocking)
-
No tests added - The LSP config module lacks tests entirely, so this isn't a regression from this PR. Consider adding tests in a follow-up.
-
Node availability assumption - The comment says "bun/node are always available in oh-my-opencode context." This is mostly true since oh-my-opencode runs on bun. Node is likely available if users have JS-based LSP servers, but not guaranteed. Edge case, acceptable trade-off.
-
Relative paths -
cmd.includes("/")matches relative paths like./bin/server. These would failexistsSync(cmd)if cwd is wrong, but fall through to PATH check, so no harm.
Verdict
Ship it! π΄ββ οΈ Arrr, these scallywag servers can now be properly detected!
Review Complete β@code-yeongyu I've reviewed and approved this PR. Summary: Solid fix for custom LSP server detection on Windows. The changes are minimal, well-documented, and solve a real problem for users configuring servers like gopls with absolute paths or node-based servers. Key Points:
No blocking issues. Ready to merge! π΄ββ οΈ |
Summary
oh-my-opencode.jsonProblem (ships lost at sea, ARRRR! π΄ββ οΈ)
Users configuring custom LSP servers in their config weren't being detected as "installed":
The
isServerInstalled()function only checked PATH and some hardcoded directories, missing:nodeorbunSolution (better treasure-findin' skills π¦)
1. Absolute Path Support
If
command[0]contains/or\, verify viaexistsSync():Handles:
["C:\Users\user\go\bin\gopls.exe"]["C:\Users\...\typescript-language-server.exe", "--stdio"]["/usr/local/bin/custom-lsp"]2. Runtime Wrapper Support
If
command[0]isbunornode, assume available (oh-my-opencode runs on these):Handles:
["node", "path/to/server.js", "--stdio"]["bun", "run", "my-lsp-server"]Real-World Configs Now Working
["node", "...\server.js", "--stdio"]["node", "...\server.js", "--stdio"]["C:\...\gopls.exe"]["C:\...\typescript-language-server.exe", "--stdio"]Testing
Now these scallywag servers can be properly detected! π΄ββ οΈ