Skip to content

Commit

Permalink
feat: Add support for select.clipboard (#304)
Browse files Browse the repository at this point in the history
Useful for providing system clipboard contents easily (for example for
using CopilotChat quickly in replace mode in tmux popup etc)

Signed-off-by: Tomas Slusny <[email protected]>
  • Loading branch information
deathbeam authored May 7, 2024
1 parent c3a8ea9 commit afb1fca
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lua/CopilotChat/select.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function M.visual(source)
return get_selection_lines(bufnr, start_line, start_col, finish_line, finish_col, false)
end

--- Select and process contents of unnamed register ('"')
--- Select and process contents of unnamed register ("). This register contains last deleted, changed or yanked content.
--- @return CopilotChat.config.selection|nil
function M.unnamed()
local lines = vim.fn.getreg('"')
Expand All @@ -63,6 +63,20 @@ function M.unnamed()
}
end

--- Select and process contents of plus register (+). This register is synchronized with system clipboard.
--- @return CopilotChat.config.selection|nil
function M.clipboard()
local lines = vim.fn.getreg('+')

if not lines or lines == '' then
return nil
end

return {
lines = lines,
}
end

--- Select and process whole buffer
--- @param source CopilotChat.config.source
--- @return CopilotChat.config.selection|nil
Expand Down

0 comments on commit afb1fca

Please sign in to comment.