11# opencode.nvim
22
3- Integrate the [ opencode] ( https://github.com/sst/opencode ) AI assistant with Neovim — streamline editor-aware research, reviews, and requests.
3+ Integrate the [ opencode] ( https://github.com/sst/opencode ) AI assistant with Neovim — streamline editor-aware research, reviews, and requests.
44
5- https://github.com/user-attachments/assets/01e4e2fc-bbfa-427e-b9dc-c1c1badaa90e
5+ < https://github.com/user-attachments/assets/01e4e2fc-bbfa-427e-b9dc-c1c1badaa90e >
66
77## ✨ Features
88
9- - Auto-connects to * any * ` opencode ` running inside Neovim's CWD, or provides an integrated instance.
9+ - Auto-connects to _ any _ ` opencode ` running inside Neovim's CWD, or provides an integrated instance.
1010- Input prompts with completions, highlights, and normal-mode support.
1111- Select prompts from a library and define your own.
1212- Inject relevant editor context (buffer, cursor, selection, diagnostics, etc.).
@@ -74,31 +74,31 @@ programs.nixvim = {
7474
7575` opencode.nvim ` replaces placeholders in prompts with the corresponding context:
7676
77- | Placeholder | Context |
78- | - | - |
79- | ` @this ` | Visual selection if any, else cursor position |
80- | ` @buffer ` | Current buffer |
81- | ` @buffers ` | Open buffers |
82- | ` @visible ` | Visible text |
83- | ` @diagnostics ` | Current buffer diagnostics |
84- | ` @quickfix ` | Quickfix list |
85- | ` @diff ` | Git diff |
86- | ` @grapple ` | [ grapple.nvim] ( https://github.com/cbochs/grapple.nvim ) tags |
77+ | Placeholder | Context |
78+ | -------------- | ---------------------------------------------------------- - |
79+ | ` @this ` | Visual selection if any, else cursor position |
80+ | ` @buffer ` | Current buffer |
81+ | ` @buffers ` | Open buffers |
82+ | ` @visible ` | Visible text |
83+ | ` @diagnostics ` | Current buffer diagnostics |
84+ | ` @quickfix ` | Quickfix list |
85+ | ` @diff ` | Git diff |
86+ | ` @grapple ` | [ grapple.nvim] ( https://github.com/cbochs/grapple.nvim ) tags |
8787
8888### Prompts
8989
9090Select or reference prompts to review, explain, and improve your code:
9191
92- | Name | Prompt |
93- | ------------------------------------| ----------------------------------------------------------- |
94- | ` diagnostics ` | Explain ` @diagnostics ` |
95- | ` diff ` | Review the following git diff for correctness and readability: ` @diff ` |
96- | ` document ` | Add comments documenting ` @this ` |
97- | ` explain ` | Explain ` @this ` and its context |
98- | ` fix ` | Fix ` @diagnostics ` |
99- | ` optimize ` | Optimize ` @this ` for performance and readability |
100- | ` review ` | Review ` @this ` for correctness and readability |
101- | ` test ` | Add tests for ` @this ` |
92+ | Name | Prompt |
93+ | ------------- | ---------------------------------------------------------------------- |
94+ | ` diagnostics ` | Explain ` @diagnostics ` |
95+ | ` diff ` | Review the following git diff for correctness and readability: ` @diff ` |
96+ | ` document ` | Add comments documenting ` @this ` |
97+ | ` explain ` | Explain ` @this ` and its context |
98+ | ` fix ` | Fix ` @diagnostics ` |
99+ | ` optimize ` | Optimize ` @this ` for performance and readability |
100+ | ` review ` | Review ` @this ` for correctness and readability |
101+ | ` test ` | Add tests for ` @this ` |
102102
103103### Provider
104104
@@ -112,14 +112,53 @@ If `opencode.nvim` can't find an existing `opencode`, it uses the configured pro
112112``` lua
113113vim .g .opencode_opts = {
114114 provider = {
115- enabled = " snacks" , -- Default if `snacks.terminal` is available and enabled.
115+ enabled = " snacks" ,
116116 snacks = {
117- -- Customize `snacks.terminal` to your liking.
117+ -- ...
118+ }
119+ }
120+ }
121+ ```
122+
123+ </details >
124+
125+ <details >
126+ <summary ><a href =" https://sw.kovidgoyal.net/kitty/ " >kitty</a ></summary >
127+
128+ ``` lua
129+ vim .g .opencode_opts = {
130+ provider = {
131+ enabled = " kitty" ,
132+ kitty = {
133+ -- ...
118134 }
119135 }
120136}
121137```
122138
139+ The kitty provider requires [ remote control via a socket] ( https://sw.kovidgoyal.net/kitty/remote-control/#remote-control-via-a-socket ) to be enabled.
140+
141+ You can do this either by running Kitty with the following command:
142+
143+ ``` bash
144+ # For Linux only:
145+ kitty -o allow_remote_control=yes --single-instance --listen-on unix:@mykitty
146+
147+ # Other UNIX systems:
148+ kitty -o allow_remote_control=yes --single-instance --listen-on unix:/tmp/mykitty
149+ ```
150+
151+ OR, by adding the following to your ` kitty.conf ` :
152+
153+ ```
154+ # For Linux only:
155+ allow_remote_control yes
156+ listen_on unix:@mykitty
157+ # Other UNIX systems:
158+ allow_remote_control yes
159+ listen_on unix:/tmp/kitty
160+ ```
161+
123162</details >
124163
125164<details >
@@ -128,9 +167,9 @@ vim.g.opencode_opts = {
128167``` lua
129168vim .g .opencode_opts = {
130169 provider = {
131- enabled = " tmux" , -- Default if inside a `tmux` session.
170+ enabled = " tmux" ,
132171 tmux = {
133- options = " -h " , -- Options to pass to `tmux split-window` .
172+ -- .. .
134173 }
135174 }
136175}
@@ -200,24 +239,24 @@ Prompt `opencode`.
200239
201240Command ` opencode ` :
202241
203- | Command | Description |
204- | ------------------------- | ---------------------------------------------------------- |
205- | ` session.list ` | List sessions |
206- | ` session.new ` | Start a new session |
207- | ` session.share ` | Share the current session |
208- | ` session.interrupt ` | Interrupt the current session |
209- | ` session.compact ` | Compact the current session (reduce context size) |
210- | ` session.page.up ` | Scroll messages up by one page |
211- | ` session.page.down ` | Scroll messages down by one page |
212- | ` session.half.page.up ` | Scroll messages up by half a page |
213- | ` session.half.page.down ` | Scroll messages down by half a page |
214- | ` session.first ` | Jump to the first message in the session |
215- | ` session.last ` | Jump to the last message in the session |
216- | ` session.undo ` | Undo the last action in the current session |
217- | ` session.redo ` | Redo the last undone action in the current session |
218- | ` prompt.submit ` | Submit the TUI input |
219- | ` prompt.clear ` | Clear the TUI input |
220- | ` agent.cycle ` | Cycle the selected agent |
242+ | Command | Description |
243+ | ------------------------ | -------------------------------------------------- |
244+ | ` session.list ` | List sessions |
245+ | ` session.new ` | Start a new session |
246+ | ` session.share ` | Share the current session |
247+ | ` session.interrupt ` | Interrupt the current session |
248+ | ` session.compact ` | Compact the current session (reduce context size) |
249+ | ` session.page.up ` | Scroll messages up by one page |
250+ | ` session.page.down ` | Scroll messages down by one page |
251+ | ` session.half.page.up ` | Scroll messages up by half a page |
252+ | ` session.half.page.down ` | Scroll messages down by half a page |
253+ | ` session.first ` | Jump to the first message in the session |
254+ | ` session.last ` | Jump to the last message in the session |
255+ | ` session.undo ` | Undo the last action in the current session |
256+ | ` session.redo ` | Redo the last undone action in the current session |
257+ | ` prompt.submit ` | Submit the TUI input |
258+ | ` prompt.clear ` | Clear the TUI input |
259+ | ` agent.cycle ` | Cycle the selected agent |
221260
222261## 👀 Events
223262
0 commit comments