@@ -48,6 +48,7 @@ Integrate the [opencode](https://github.com/sst/opencode) AI assistant with Neov
4848 vim .keymap .set ({ " n" , " x" }, " go" , function () return require (" opencode" ).operator (" @this " ) end , { desc = " Add range to opencode" , expr = true })
4949 vim .keymap .set (" n" , " goo" , function () return require (" opencode" ).operator (" @this " ) .. " _" end , { desc = " Add line to opencode" , expr = true })
5050
51+ -- The default <C-u>/<C-d> keymaps will work in the normal mode but it is possible to scroll opencode from any buffer:
5152 vim .keymap .set (" n" , " <S-C-u>" , function () require (" opencode" ).command (" session.half.page.up" ) end , { desc = " Scroll opencode up" })
5253 vim .keymap .set (" n" , " <S-C-d>" , function () require (" opencode" ).command (" session.half.page.down" ) end , { desc = " Scroll opencode down" })
5354
@@ -79,17 +80,17 @@ programs.nixvim = {
7980
8081` opencode.nvim ` replaces placeholders in prompts with the corresponding context:
8182
82- | Placeholder | Context |
83- | -------------- | ------------------------------------------------------------- |
84- | ` @this ` | Operator range or visual selection if any, else cursor position |
85- | ` @buffer ` | Current buffer |
86- | ` @buffers ` | Open buffers |
87- | ` @visible ` | Visible text |
88- | ` @diagnostics ` | Current buffer diagnostics |
89- | ` @quickfix ` | Quickfix list |
90- | ` @diff ` | Git diff |
91- | ` @marks ` | Global marks |
92- | ` @grapple ` | [ grapple.nvim] ( https://github.com/cbochs/grapple.nvim ) tags |
83+ | Placeholder | Context |
84+ | -------------- | --------------------------------------------------------------- |
85+ | ` @this ` | Operator range or visual selection if any, else cursor position |
86+ | ` @buffer ` | Current buffer |
87+ | ` @buffers ` | Open buffers |
88+ | ` @visible ` | Visible text |
89+ | ` @diagnostics ` | Current buffer diagnostics |
90+ | ` @quickfix ` | Quickfix list |
91+ | ` @diff ` | Git diff |
92+ | ` @marks ` | Global marks |
93+ | ` @grapple ` | [ grapple.nvim] ( https://github.com/cbochs/grapple.nvim ) tags |
9394
9495### Prompts
9596
@@ -107,6 +108,36 @@ Select or reference prompts to review, explain, and improve your code:
107108| ` review ` | Review ` @this ` for correctness and readability |
108109| ` test ` | Add tests for ` @this ` |
109110
111+ ### Keymaps
112+
113+ ` opencode.nvim ` sets these buffer-local keymaps in opencode terminal buffers by default:
114+
115+ | Keymap | Command | Description |
116+ | ------- | ------------------------ | --------------------- |
117+ | ` <C-u> ` | ` session.half.page.up ` | Scroll up half page |
118+ | ` <C-d> ` | ` session.half.page.down ` | Scroll down half page |
119+ | ` gg ` | ` session.first ` | Go to first message |
120+ | ` G ` | ` session.last ` | Go to last message |
121+
122+ You can customize or disable these keymaps:
123+
124+ ``` lua
125+ vim .g .opencode_opts = {
126+ -- Customize keymaps
127+ keymaps = {
128+ n = {
129+ [" <C-u>" ] = { " session.half.page.up" , desc = " Scroll up" },
130+ [" <C-d>" ] = { " session.half.page.down" , desc = " Scroll down" },
131+ [" gg" ] = false , -- Disable this keymap
132+ -- Add custom keymaps
133+ [" <C-n>" ] = { " session.new" , desc = " New session" },
134+ },
135+ },
136+ -- Or disable all default keymaps
137+ -- keymaps = false,
138+ }
139+ ```
140+
110141### Provider
111142
112143You can manually run ` opencode ` inside Neovim's CWD however you like and ` opencode.nvim ` will find it!
0 commit comments