Repository navigation
[Bug]: Symbol references highlight ordinary words in assistant prose #558
Description
Description
Assistant replies in the output window highlight ordinary English words as symbol references (OpencodeSymbolReference), and gd/<CR> on those words offer jumps to unrelated locals. With only lua/opencode/ui/session_diff.lua loaded, short replies light up to, first, line, existing, current, file, apply and update (screenshots below). In a larger TypeScript project I get dozens of highlighted words per reply.
The symbol scan doesn't distinguish prose from code. _format_assistant_message tokenizes every line of a text part with symbol_tokens.find and keeps any token that symbol_snapshot.targets_for_token resolves in a candidate file (formatter.lua#L753-L884). Nothing checks for inline code or fenced blocks.
Before #489, a token was only checked against files referenced earlier in the same message (formatter.lua#L856-L868 at cdf00c5), which kept prose matches rare. #489 widened the candidates to every readable file from the conversation plus every loaded buffer (reference_facts.lua#L237-L259) while still scanning the whole reply, so any common word that is a local name somewhere in those files matches.
Expected: symbol references only inside inline code and fenced code blocks, which is where replies put identifiers. If bare identifiers in prose should stay jumpable, prose could be limited to tokens that look like code (containing _, ., :: or an inner capital): that keeps switch_to_mode and drops to and line. An option to turn symbol references off would also help; overriding the highlight group hides the colour, but the jump targets stay.
Steps to reproduce
- From the repo root, start the replay harness with nvim-treesitter's queries on the runtimepath (Neovim 0.12 ships no Lua
localsquery):
./tests/manual/run_replay.sh --cmd 'set rtp+=/path/to/nvim-treesitter/runtime'(the directory that containsqueries/lua/locals.scm) - Load a plugin file into a buffer. The focused panel window has
winfixbuf, so::call bufload(bufadd('lua/opencode/ui/session_diff.lua')) :ReplayLoad tests/data/redo-all.json:lua require('tests.helpers').restore_replay_environment().:ReplayLoadstubsreference_facts.available_files()to return{}, which hides this in replays.:ReplayAll- The replies highlight
to,first,line,existing,current,file,applyandupdate.gdonfirstin "to the first line" offers threefirstlocals fromsession_diff.lua.
Environment
- Neovim version: 0.12.4
- OpenCode version: 1.19.0 (not used by the replay)
- opencode.nvim version or commit: 93b0536 (current
main) - OS: macOS 27.0.1 (arm64)
Configuration
OpenCode configuration
Not involved; the replay doesn't talk to a server.
opencode.nvim configuration
Defaults from tests/manual/init_replay.lua. The screenshots are from my own config, which sets preferred_picker = 'snacks'.
Logs and screenshots
The replay above with only session_diff.lua loaded:
gd on "first" in "to the first line":
Checklist
- I have searched existing issues.
- I have included all relevant details.
- I have removed sensitive information from configs and logs.


Activity