Repository navigation
Plugin ideas for OpenCode v2 #334
Replies: 3 comments 4 replies
To be honest, this is probably my biggest gripe with the Opencode TUI right now. I really miss the VIM motions and operators if I need to edit a prompt midway through writing it.
This appears to be the rub from what I've been gathering. Much of the TUI behavior support was changed or dropped at v2, which creates a lot of friction. To be clear though, at least for my usage pattern, I would still prefer this as I frequently run a Herdr pane with Opencode on one side, and another terminal on the other in which I may or may not be in Neovim. I would rather not be required to be in neovim to get the functionality I want. My opinion is that idea 2 is going to be more trouble than it's worth, and it looks like you already agree. However I also can't help but wonder if using an Opencode TUI from within a shell in Neovim would help capture the TUI client in an easier way, and similarly if the Neovim shell might help standardize the target in any way and make option 2 more realistic. |
Option 1 research (custom OpenCode plugin to re-instate TUI endpoints)How it'd work
So we'd need two plugins - one for the server, one for the CLI/TUI. What it could doLikely restore most TUI endpoints, but not prompt append. Cost
Sooo seems like a bad option. Lots of work and maintenance, and still can't give us everything we want. I'll brainstorm on Option 3 next. |
|
Not a solution for the session-targeting problem, but a data point in case it inspires something. I dropped the plugin for v2 and made Neovim act as the editor the TUI connects to, using the TUI's built-in editor integration (the Claude Code IDE protocol). It is a small Lua module with no dependencies: a loopback WebSocket server on What it gives:
#318 already implements the same protocol (lock file, WebSocket,
|
| Mention | URI | Lines attached | File size |
|---|---|---|---|
btop/btop.conf#3-5 |
...?start=3&end=5 |
3 | 286 lines |
btop/btop.conf#28-30 |
...?start=28&end=30 |
3 | 286 lines |
btop/btop.conf#46-61 |
...?start=46&end=61 |
16 | 286 lines |
ci-netns/ci-netns-setup.sh#11-17 |
...?start=11&end=17 |
7 | 59 lines |
The range only comes through at_mentioned. Typed by hand, @file#N-M gave me no range in any of my attempts: either no attachment, or the whole file with #N-M left as plain text after the mention.
Limitations I hit on 2.0.32
at_mentionedalways produces an@attachment (the prefix is hardcoded ininsertPart), so it cannot append plain text.tui.prompt.appendis still handled by the TUI, but nothing can publish it.- A one-line range (
lineStart == lineEnd) attaches from that line to the end of the file: tui: single-line file mention (lineStart == lineEnd, or "#N") attaches from that line to the end of the file anomalyco/opencode#58033. I sendN..N+1as a workaround. - The 20 MB attachment limit is checked on the whole file before the range is applied, so a range does not help with large files.
- Several TUIs in the same directory all match the same lock. I did not test it, but
OPENCODE_EDITOR_SSE_PORTshould pin one.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Spun out of #322.
Good paraphrased summary by @nikfp of OpenCode v2 and how it affects opencode.nvim:
We already have https://github.com/sudo-tee/opencode.nvim as a Neovim-native client, and it looks to be under active development still. So I'd like to focus on maximizing this plugin's "bridge" philosophy within OpenCode v2's constraints. It minimizes maintenance burden/feature creep and the barrier to entry.
My high-level ideas:
send-keysto imitate the/tui/*endpoints. Similar issues as the OG Providers: finnicky, super high-maintenance, doesn't support every workflow. Although this text-only solution would have less surface area than Providers, which managedopencode's entire lifecycle. Restores functionality and reliable targeting.main. See this commit for functionality consequences. Then improve the opencode.nvim prompting experience rather than rely on the TUI. Multi-line input, append to an in-memory prompt, agent selection, filesystem completions, (custom command completions to replace the commands section inselect()?), etc. Restores functionality, just in a different way. And maybe even a better way, because I'm sure Neovim users would prefer to write their prompts in Neovim. However this leaves correct-session targeting. Some ideas there are to create new sessions ourselves so we know the ID to then send to. And a session picker that controls which session we send to (as opposed to selecting a session in the TUI like it used to). Display selected session in statusline component for visibility. Probably some other stuff I'm missing.Open to feedback and other ideas!
Related issues:
All reactions