Skip to content

Commit f89e4d5

Browse files
committed
Add documentation for selections to README
Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
1 parent 7890192 commit f89e4d5

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,47 @@ You can define custom contexts like this:
246246
}
247247
```
248248

249+
### Selections
250+
251+
Selections are used to determine the source of the chat (so basically what to chat about).
252+
Selections are configurable either by default or by prompt.
253+
Default selection is `visual` or `buffer` (if no visual selection).
254+
Default supported selections are:
255+
256+
- `select.visual` - Includes visual selection in chat context.
257+
- `select.buffer` - Includes entire buffer in chat context.
258+
- `select.line` - Includes current line in chat context.
259+
- `select.unnamed` - Includes unnamed register in chat context.
260+
- `select.clipboard` - Includes clipboard in chat context.
261+
262+
You can define custom selection functions like this:
263+
264+
```lua
265+
{
266+
selection = function()
267+
-- Get content from * register
268+
local lines = vim.fn.getreg('*')
269+
if not lines or lines == '' then
270+
return nil
271+
end
272+
273+
return {
274+
lines = lines,
275+
}
276+
end
277+
}
278+
```
279+
280+
Or chain multiple selections like this:
281+
282+
```lua
283+
{
284+
selection = function(source)
285+
return select.visual(source) or select.buffer(source)
286+
end
287+
}
288+
```
289+
249290
### API
250291

251292
```lua

0 commit comments

Comments
 (0)