From 0149238e8aea9e1a65bfdb08e4f0a9688ecb5664 Mon Sep 17 00:00:00 2001 From: Sjon-Paul Brown <81941908+sjonpaulbrown-cc@users.noreply.github.com> Date: Fri, 9 Aug 2024 08:42:38 -0600 Subject: [PATCH] Add support for overriding the default yank_diff register (#389) --- README.md | 2 ++ lua/CopilotChat/config.lua | 3 +++ lua/CopilotChat/init.lua | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6d6d8829..4e0e77b6 100644 --- a/README.md +++ b/README.md @@ -199,6 +199,8 @@ Also see [here](/lua/CopilotChat/config.lua): proxy = nil, -- [protocol://]host[:port] Use this proxy allow_insecure = false, -- Allow insecure server connections + yank_diff_register = '"', -- Allow overriding the register for yanking diffs + system_prompt = prompts.COPILOT_INSTRUCTIONS, -- System prompt to use model = 'gpt-4o', -- GPT model to use, 'gpt-3.5-turbo', 'gpt-4', or 'gpt-4o' temperature = 0.1, -- GPT temperature diff --git a/lua/CopilotChat/config.lua b/lua/CopilotChat/config.lua index 5fa09cd7..644c946d 100644 --- a/lua/CopilotChat/config.lua +++ b/lua/CopilotChat/config.lua @@ -58,6 +58,7 @@ local select = require('CopilotChat.select') ---@field proxy string? ---@field allow_insecure boolean? ---@field system_prompt string? +---@field yank_diff_register string? ---@field model string? ---@field temperature number? ---@field question_header string? @@ -82,6 +83,8 @@ return { proxy = nil, -- [protocol://]host[:port] Use this proxy allow_insecure = false, -- Allow insecure server connections + yank_diff_register = '"', -- Allows overriding the register for yanking diffs + system_prompt = prompts.COPILOT_INSTRUCTIONS, -- System prompt to use model = 'gpt-4o-2024-05-13', -- GPT model to use, 'gpt-3.5-turbo', 'gpt-4', or `gpt-4o-2024-05-13` temperature = 0.1, -- GPT temperature diff --git a/lua/CopilotChat/init.lua b/lua/CopilotChat/init.lua index 1e39bc0f..1c2cf88c 100644 --- a/lua/CopilotChat/init.lua +++ b/lua/CopilotChat/init.lua @@ -774,7 +774,7 @@ function M.setup(config) local lines = find_lines_between_separator(section_lines, '^```%w*$', true) if #lines > 0 then local content = table.concat(lines, '\n') - vim.fn.setreg('"', content) + vim.fn.setreg(M.config.yank_diff_register, content) end end)