Skip to content

Commit

Permalink
feat: add yank action to code edits (#418)
Browse files Browse the repository at this point in the history
  • Loading branch information
petobens committed Jun 22, 2024
1 parent a8b5520 commit a254f6c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lua/chatgpt/code_edits.lua
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,16 @@ M.edit_with_instructions = function(output_lines, bufnr, selection, ...)
end, { noremap = true })
end

-- yank output window
for _, mode in ipairs({ "n", "i" }) do
instructions_input:map(mode, Config.options.edit_with_instructions.keymaps.yank, function()
instructions_input.input_props.on_close()
local lines = vim.api.nvim_buf_get_lines(output_window.bufnr, 0, -1, false)
vim.fn.setreg(Config.options.yank_register, lines)
vim.notify("Successfully copied to yank register!", vim.log.levels.INFO)
end, { noremap = true })
end

-- use output as input
for _, mode in ipairs({ "n", "i" }) do
instructions_input:map(mode, Config.options.edit_with_instructions.keymaps.use_output_as_input, function()
Expand Down
1 change: 1 addition & 0 deletions lua/chatgpt/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function M.defaults()
keymaps = {
close = "<C-c>",
accept = "<C-y>",
yank = "<C-u>",
toggle_diff = "<C-d>",
toggle_settings = "<C-o>",
toggle_help = "<C-h>",
Expand Down

0 comments on commit a254f6c

Please sign in to comment.