Skip to content

Commit 252f4af

Browse files
committed
feat: add inline visual selection insertion action
Add new action `add_visual_selection_inline` with keymap `<leader>oY` to insert visually selected code directly into the input buffer as a Markdown code block, prefixed with the file path. Updates documentation with usage details and example. Leaves cursor in normal mode for prompt editing.
1 parent 3cc37a3 commit 252f4af

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ require('opencode').setup({
148148
['<leader>op'] = { 'configure_provider' }, -- Quick provider and model switch from predefined list
149149
['<leader>oV'] = { 'configure_variant' }, -- Switch model variant for the current model
150150
['<leader>oy'] = { 'add_visual_selection', mode = {'v'} },
151+
['<leader>oY'] = { 'add_visual_selection_inline', mode = {'v'} }, -- Insert visual selection as inline code block in the input buffer
151152
['<leader>oz'] = { 'toggle_zoom' }, -- Zoom in/out on the Opencode windows
152153
['<leader>ov'] = { 'paste_image'}, -- Paste image from clipboard into current session
153154
['<leader>od'] = { 'diff_open' }, -- Opens a diff tab of a modified file since the last opencode prompt
@@ -645,6 +646,7 @@ The plugin provides the following actions that can be triggered via keymaps, com
645646
| Toggle reasoning output (thinking steps) | `<leader>otr` | `:Opencode toggle_reasoning_output` | `require('opencode.api').toggle_reasoning_output()` |
646647
| Open a quick chat input with selection/current line context | `<leader>o/` | `:Opencode quick_chat` | `require('opencode.api').quick_chat()` |
647648
| Add visual selection to context | `<leader>oy` | `:Opencode add_visual_selection` | `require('opencode.api').add_visual_selection(opts?)` |
649+
| Insert visual selection inline into input | `<leader>oY` | `:Opencode add_visual_selection_inline` | `require('opencode.api').add_visual_selection_inline(opts?)` |
648650

649651
**add_visual_selection opts:**
650652

@@ -653,9 +655,21 @@ The plugin provides the following actions that can be triggered via keymaps, com
653655
Example keymap for silent add:
654656

655657
```lua
656-
['<leader>oY'] = { 'add_visual_selection', { open_input = false }, mode = {'v'} }
658+
['<leader>oy'] = { 'add_visual_selection', { open_input = false }, mode = {'v'} }
657659
```
658660

661+
**add_visual_selection_inline** inserts the visually selected code directly into the input buffer as a Markdown code block, prefixed with the file path:
662+
663+
```
664+
**`path/to/file.lua`**
665+
666+
```lua
667+
<selected text>
668+
```
669+
```
670+
671+
The cursor is left in normal mode in the input buffer so you can type your prompt around the inserted snippet.
672+
659673
### Run opts
660674
661675
You can pass additional options when running a prompt via command or API:

0 commit comments

Comments
 (0)