give the agent some active neovim abilities and one-shot non-interactive edits #311
Replies: 1 comment 2 replies
|
Thanks for your ideas!
I agree this is neat and I'm working on it already, but with an IMO better, simpler implementation. The plugin listens for file-related events from OpenCode (atm I like the one-shot idea and have toyed with it before. Ultimately I decided against it. It's too specific and requires lots of code. opencode.nvim focuses on bridging Neovim and the OpenCode TUI for simplicity and familiarity. Background prompting is an entirely different code path and would scope-creep into re-implementing lots of TUI stuff. Not to mention whatever it'd take to restrict OpenCode to editing a specific area. You might be able to compose opencode.nvim APIs to create one-shot-like behavior though. Create a new session, send your prompt to it (optionally including So I think these are neat ideas but imo they fit better outside opencode.nvim 🙂 |
Uh oh!
There was an error while loading. Please reload this page.
Tldr; I'm proposing two things: a small opencode plugin to open up better interaction for the agent with neovim (most notably: and taking a little bit of inspiration from 99.
Problem
I'm currently trying to regain more control and clarity over agentic code. My current setup is opencode.nvim (opencode running in a floaterm, and I'm trying to force myself to never open opencode outside nvim), 99 and a up until very recently a neovim mcp, which I have ditched for a skill, that explains how to use the
--remote-exprto do some things with neovim. Running opencode inside neovim is actually great for opencode->neovim interactions, because the socket path is trivially available.I generally use opencode.nvim as talking with the agent is of course very valuable and the plugin is great in sending in context etc. There are two things I use 99 for: one is the one-shot background exploration agent which you ask a question and loads the resulting places it finds into the quickfix list and the one where you visual select an area and it rewrites that area (has a fun indicator too that it's happening), which is also a one-shot one, so it's very focused and much closer to you writing a small bit of code with a very fancy autocomplete. I like that you can do some parallel work that doesn't get into your "main" agents context, and has a visual indicator that it's happening in the background.
But I have several gripes with this setup also:
--remote-exprsolution is also terrible for security, since it's basically an arbitrary code execution path for the agent, so I'm forced to accept prompts every timeProposal
companion plugin in opencode
Add a small companion opencode plugin, which provides neovim tool(s) for opencode. Should be probably gated behind the existence of $NVIM or something like that, so it only pollutes context when it makes sense. Since it's a plugin for opencode it will naturally be opt-in for user. The most important capability would be to load entries into the quickfix list and to provide a replacement mechanism for given marks in nvim (for the edit this, and just this selection). Some other things it could do: read cursor position, visual selection position, buffer list etc. I think the only writing capability should really be the quickfix list, which is innocent enough usually, and is a very natural place to put info in vim.
better background support in opencode.nvim
This is two parts:
a) add support for one-shot non-interactive agent invocations that either rewrite a very specific area only (so no it's not the agent's edit tool doing the edits, because that can go all over, but very specifically to a controlled area) or searches where the input is not the entire main agent session, just a simple prompt then and there with some cursor/selection position info and the output is just the quickfix list and
b) if either a one-shot agent is running or the main opencode instance is running, but is not actually visible show a "running" indicator (I'm not sure detecting visibility is trivial with so many way to connect to an instance, so maybe it could be always there if something is running, opt-in obviously).
Notes
Obviously the quickfix list tool makes sense in the main agent as well for more interactive things, while the "edit this specific area" is not usable this way since since the marks in neovim won't be set for it. Also, with 99 I've seen that for the background agents you need to make a special non-visible agent in opencode that has edit, bash, tasks and todowrite disabled to make them work.
What do you think, could these be in scope for opencode.nvim?
All reactions