-
-
Notifications
You must be signed in to change notification settings - Fork 98
Description
Did you check the docs?
- I have read all the docs
Is your feature request related to a problem? Please describe.
From the discussion in #150.
It's not practical for opencode.nvim to support all the ways users may want to find their opencode server. But I really like that convenience.
Describe the solution you'd like
Expose a way for users (and supplemental plugins like https://github.com/e-cal/opencode-tmux.nvim) to hook into the server discovery process.
Hook configuration methods
opts.server.pid: a function that returnsopencodeserver PIDs. Lowest burden on users - a PID is the simplest form possible, and thenopencode.nvimconverts it to a port and then server object.- Extend
opts.server.portto alsofun(): number[]. I like that it keeps a single option. But it probably requires some user work to provide a port. opts.server.discover: a function that returnsServerobjects. Requires lots of work on user's end.opts.server.url: Similar toopts.server.port, but would support feature: easier way to just specify the server endpoint #190. Probably replaceopts.server.port.
I would like to type this in an obvious way. Primarily, I wonder if these options should be mutually exclusive.
I also wonder if we should default the new option to find all servers, prioritizing ones with matching CWDs. The plugin already does that internally. The question is whether that should be completely overridable, or always supplement this new configured option.
Order of priority when discovering servers
Currently:
- Currently connected server
- Configured port
- Single server partially matching Neovim's CWD
- Prompt user to select from all servers
Proposed:
Depends on the configuration method chosen above. But something like:
- Currently connected server
- Configured port
- Single server returned by new discovery hook
- Prompt user to select from all servers returned by new discovery hook
- Single server partially matching Neovim's CWD
- Prompt user to select from all servers
We could expose a sort option. But I'd love to find a good enough default that that's not necessary.
Describe alternatives you've considered
Monkeypatch server.lua#get like https://github.com/e-cal/opencode-tmux.nvim does. But it's unstable and duplicates work that opencode.nvim should be able to handle on its behalf.
Additional context
No response