File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff 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 that live in ` local select = require("CopilotChat.select") ` are:
255+
256+ - ` select.visual ` - Current visual selection. Works well with diffs.
257+ - ` select.buffer ` - Current buffer content. Works well with diffs.
258+ - ` select.line ` - Current line content. Works decently with diffs.
259+ - ` select.unnamed ` - Content from the unnamed register.
260+ - ` select.clipboard ` - Content from system clipboard.
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
You can’t perform that action at this time.
0 commit comments