Skip to content

Commit

Permalink
feat: add a keybinding config for ChatFinder (#209)
Browse files Browse the repository at this point in the history
* add a keybinding config for ChatFinder(now only delete keybinding)

* fix modes typo
  • Loading branch information
LLMChild authored Sep 19, 2024
1 parent 6acf46c commit a88225e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions lua/gp/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,9 @@ local config = {
chat_shortcut_new = { modes = { "n", "i", "v", "x" }, shortcut = "<C-g>c" },
-- default search term when using :GpChatFinder
chat_finder_pattern = "topic ",
chat_finder_mappings = {
delete = { modes = { "n", "i", "v", "x" }, shortcut = "<C-d>" },
},
-- if true, finished ChatResponder won't move the cursor to the end of the buffer
chat_free_cursor = false,
-- use prompt buftype for chats (:h prompt-buffer)
Expand Down
7 changes: 4 additions & 3 deletions lua/gp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,7 @@ M.cmd.ChatFinder = function()
M._chat_finder_opened = true

local dir = M.config.chat_dir
local delete_shortcut = M.config.chat_finder_mappings.delete or M.config.chat_shortcut_delete

-- prepare unique group name and register augroup
local gid = M.helpers.create_augroup("GpChatFinder", { clear = true })
Expand All @@ -1205,7 +1206,7 @@ M.cmd.ChatFinder = function()
local right = M.config.style_chat_finder_margin_right or 2
local picker_buf, picker_win, picker_close, picker_resize = M.render.popup(
nil,
"Picker: j/k <Esc>|exit <Enter>|open " .. M.config.chat_shortcut_delete.shortcut .. "|del i|srch",
"Picker: j/k <Esc>|exit <Enter>|open " .. delete_shortcut.shortcut .. "|del i|srch",
function(w, h)
local wh = h - top - bottom - 2
local ww = w - left - right - 2
Expand Down Expand Up @@ -1457,8 +1458,8 @@ M.cmd.ChatFinder = function()
-- dd on picker or preview window will delete file
M.helpers.set_keymap(
{ command_buf, picker_buf, preview_buf },
{ "i", "n", "v" },
M.config.chat_shortcut_delete.shortcut,
delete_shortcut.modes,
delete_shortcut.shortcut,
function()
local index = vim.api.nvim_win_get_cursor(picker_win)[1]
local file = picker_files[index]
Expand Down

0 comments on commit a88225e

Please sign in to comment.