File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -293,6 +293,49 @@ You can define custom contexts like this:
293293<
294294
295295
296+ SELECTIONS ~
297+
298+ Selections are used to determine the source of the chat (so basically what to
299+ chat about). Selections are configurable either by default or by prompt.
300+ Default selection is `visual ` or `buffer ` (if no visual selection). Default
301+ supported selections that live in `local select =
302+ require("CopilotChat.select")` are:
303+
304+ - `select.visual ` - Current visual selection. Works well with diffs.
305+ - `select.buffer ` - Current buffer content. Works well with diffs.
306+ - `select.line ` - Current line content. Works decently with diffs.
307+ - `select.unnamed` - Content from the unnamed register.
308+ - `select.clipboard ` - Content from system clipboard.
309+
310+ You can define custom selection functions like this:
311+
312+ >lua
313+ {
314+ selection = function()
315+ -- Get content from * register
316+ local lines = vim.fn.getreg('*')
317+ if not lines or lines == '' then
318+ return nil
319+ end
320+
321+ return {
322+ lines = lines,
323+ }
324+ end
325+ }
326+ <
327+
328+ Or chain multiple selections like this:
329+
330+ >lua
331+ {
332+ selection = function(source)
333+ return select.visual(source) or select.buffer(source)
334+ end
335+ }
336+ <
337+
338+
296339API ~
297340
298341>lua
You can’t perform that action at this time.
0 commit comments