Skip to content

Commit a88225e

Browse files
authored
feat: add a keybinding config for ChatFinder (#209)
* add a keybinding config for ChatFinder(now only delete keybinding) * fix modes typo
1 parent 6acf46c commit a88225e

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lua/gp/config.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@ local config = {
313313
chat_shortcut_new = { modes = { "n", "i", "v", "x" }, shortcut = "<C-g>c" },
314314
-- default search term when using :GpChatFinder
315315
chat_finder_pattern = "topic ",
316+
chat_finder_mappings = {
317+
delete = { modes = { "n", "i", "v", "x" }, shortcut = "<C-d>" },
318+
},
316319
-- if true, finished ChatResponder won't move the cursor to the end of the buffer
317320
chat_free_cursor = false,
318321
-- use prompt buftype for chats (:h prompt-buffer)

lua/gp/init.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,6 +1192,7 @@ M.cmd.ChatFinder = function()
11921192
M._chat_finder_opened = true
11931193

11941194
local dir = M.config.chat_dir
1195+
local delete_shortcut = M.config.chat_finder_mappings.delete or M.config.chat_shortcut_delete
11951196

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

0 commit comments

Comments
 (0)