anomalyco / anomalyco/opencode
[BUG] Experimental LSP tool returns empty results instead of initialization errors for nested Rust workspace
@nexxeln is already working on this.
Since Aug 4, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- Avg merge
- 7h 2m
- Merged PRs (30d)
- 384
Description
Description
Summary
The experimental OpenCode LSP tool is exposed and callable, but it does not produce usable Rust workspace results for a valid nested Cargo project. More importantly, apparent infrastructure or initialization failure is surfaced as an authoritative empty answer ([], [null], or No results found) rather than as an error.
That makes it difficult for a coding agent to distinguish “this symbol genuinely has no references” from “the language server never loaded the workspace.”
Environment
- OpenCode:
1.18.12 - OS: Windows 11
- Language server:
rust-analyzer, installed through the Rust toolchain - Repository layout:
<git-root>/tethers-0.1/host-rust/Cargo.toml
The Rust crate is nested below the Git repository root.
OpenCode was launched in a fresh console process with process-local environment variables:
OPENCODE_EXPERIMENTAL_LSP_TOOL=true
OPENCODE_DISABLE_LSP_DOWNLOAD=true
The real OpenCode CLI executable was used, not the desktop GUI executable.
Observed behaviour
For known Rust functions, fields, and symbols that definitely exist and have references:
goToDefinitionreturnedNo results foundfindReferencesreturnedNo results foundhoverreturned[null]documentSymbolreturned no resultsworkspaceSymbolreturned no resultsopencode debug lsp document-symbols <valid-file-uri>returned[]with exit code zero- a second fresh targeted session, using real zero-based positions at known call sites, timed out after approximately 244 seconds without usable LSP output
The same definitions and references were immediately discoverable with rg, and the Rust project compiled and passed its complete test suite.
Why this is risky
The current result shape does not distinguish between:
- a successful query with zero results;
rust-analyzernot starting;- the wrong workspace root being selected;
- Cargo metadata or workspace initialization failing;
- the document not being opened or indexed;
- indexing still being in progress;
- the request timing out or the client/server bridge failing.
An agent may therefore treat a language-server failure as valid code-navigation evidence and make an unsafe edit.
Expected behaviour
When the language server or workspace is not ready, the LSP tool should return an explicit error or status rather than an empty successful result.
Ideally the tool would expose enough diagnostic state to identify:
- selected workspace root;
- language-server process status;
- initialization or Cargo metadata errors;
- whether the file belongs to the loaded workspace;
- whether indexing is still in progress;
- request timeout.
A bounded timeout would also be preferable to a request hanging for several minutes.
Suggested fallback behaviour
If OpenCode cannot prove that the server is initialized and the document/workspace is loaded, return a clear failure such as:
LSP unavailable: rust-analyzer did not initialize this workspace
rather than [], [null], or No results found.
The feature is marked experimental, so occasional failure is understandable. The important issue is that failure currently looks indistinguishable from a valid empty answer.
Plugins
No response
OpenCode version
No response
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.