diff --git a/lua/CopilotChat/select.lua b/lua/CopilotChat/select.lua index 1e3ade8d..e21ea69f 100644 --- a/lua/CopilotChat/select.lua +++ b/lua/CopilotChat/select.lua @@ -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('"') @@ -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