ChatGPT.nvim
ChatGPT.nvim copied to clipboard
Add option in keymap to exit ChatGPT window while in normal mode
As of now we have this:
{
keymaps = {
close = { '<C-c>' }
}
}
Which only allow us to map an exit key while in insert mode what i want is something like this:
{
keymaps = {
close = { '<C-c>' }
close_normal = '<esc>'
}
}
The keymaps.close option is being set for both insert and normal mode, see:
https://github.com/jackMort/ChatGPT.nvim/blob/main/lua/chatgpt/module.lua#L189-L191
for _, keymap in ipairs(close_keymaps) do
chat_input:map("i", keymap, function()
chat_input.input_props.on_close()
end, { noremap = true, silent = true })
chat_input:map("n", keymap, function()
chat_input.input_props.on_close()
end, { noremap = true, silent = true })
end
I've confirmed that having the following allows me to close the window with <C-c> in both modes .
close = { "q", "<C-c>" },
I think I'll speak for a lot of users when I say that I'd like the prompt to work just like in Telescope! (i.e. Esc closes entire popup in normal mode)
@textzenith I think that would be nice too.
I don't use it, so I'm not familiar with this, but how does Telescope handle going into and out of Normal/Insert mode? Is this a feature it supports?
Would we want to exit the window with Esc in Normal mode, but not in Insert mode? This way a double press of Esc from Insert mode would exit the pop-up?
@Adoliin & @textzenith this PR https://github.com/jackMort/ChatGPT.nvim/pull/139 adds the close_normal option.
Let me know if this is what you were expecting. Cheers!
Yup exactly that's what I was looking for, hopefully it gets merged. Thanks for your contribution.
Legend!
Yes @cmpadden, that's exactly how it works. It's a bit unintuitive at first, but it's a UX most of us have become familiar with (due to Telescope's popularity), and now it feels like a sufficiently Vimmy way to handle things.
edit: I've been thinking some more about this:
In Telescope, you can press Ctrl-C from insert mode, still. But in normal mode it doesn't work — it wants to exit Neovim. Doesn't feel right. I like that in ChatGPT.nvim you can. In command mode, you can escape just by deleting (hitting backspace) at the start of the prompt. Both Telescope and ChatGPT.nvim don't allow this. Not sure if this feels right.
I would really like mappings for normal mode, and mappings for insert mode separately.