ChatGPT.nvim
ChatGPT.nvim copied to clipboard
Can't submit prompt
Hi,
After some updates, not sure when, but the enter button won't submit the prompt any more. I re-read the repo and saw this:
<C-Enter> to submit.
. However, if I press ctrl + Enter, it didn't submit but my cursor moves back to the main buffer instead of the popup. Like so:
I haven't changed any settings nor I have any key binding for <C-Enter>. Any thoughts?
My packer:
-- ChatGPT
-- Packer
use({
"jackMort/ChatGPT.nvim",
config = function()
require("chatgpt").setup({
-- optional configuration
})
end,
requires = {
"MunifTanjim/nui.nvim",
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim",
},
})
I have the same issue sporadically. It helps to leave the prompt with <C-c> and reopen it. After that submitting with <C-Enter> works.
I have the same issue sporadically. It helps to leave the prompt with and reopen it. After that submitting with works.
I tried to close the prompt and reopen it, but no luck. In my case, it's permanent, not periodically
It is happening the same to me, Enter or C-Enter just adds a new line, it won't submit my request
Some terminals don't seem to distinguish between Enter and ctrl+enter. I had the same problem and I solved it by changing the keymap like this:
use({
"jackMort/ChatGPT.nvim",
config = function()
require("chatgpt").setup({
keymaps = {
submit = "<C-s>"
}
})
end,
requires = {
"MunifTanjim/nui.nvim",
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim"
}
})
Some terminals don't seem to distinguish between Enter and ctrl+enter. I had the same problem and I solved it by changing the keymap like this:
use({ "jackMort/ChatGPT.nvim", config = function() require("chatgpt").setup({ keymaps = { submit = "<C-s>" } }) end, requires = { "MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim", "nvim-telescope/telescope.nvim" } })
This works guys :) Maybe the author of the package opened support for multiline prompt which is great! It would be nice if we can submit the prompt by <Enter> in normal mode instead, so it won't confuse different terminals
Cant't get the above to work. Nightly build. Kitty terminal.
try to remap the submit to something else, provide your config if issue still occurs
If you're using Alacritty, try adding this to your config file:
key_bindings:
# https://stackoverflow.com/a/42461580
- { key: Return, mods: Control, chars: "\x1b[13;5u" }
For the whole set:
key_bindings:
# https://stackoverflow.com/a/42461580
- { key: Return, mods: Shift, chars: "\x1b[13;2u" }
- { key: Return, mods: Control, chars: "\x1b[13;5u" }
- { key: Space, mods: Shift, chars: "\x1b[32;2u" }
- { key: Space, mods: Control, chars: "\x1b[32;5u" } # NOTE: This is an edge case and might not work.
Remapping to <C-t>
works for me. On Ubuntu using Kitty terminal.
None of the above work for me, won't submit on os X Terminal, the mapping doesn't seem to apply at all.
"jackMort/ChatGPT.nvim",
commit = '8820b99c', -- March 6th 2023, before submit issue
config = function()
require("chatgpt").setup({
...
Temporary fix, setting it back to a previous commit - need to run :PackerSync after making this change in plugins.lua - this only applies if you are using packer obv, but otherwise you can checkout that hash
"jackMort/ChatGPT.nvim", commit = '8820b99c', -- March 6th 2023, before submit issue config = function() require("chatgpt").setup({ ...
Temporary fix, setting it back to a previous commit - need to run :PackerSync after making this change in plugins.lua - this only applies if you are using packer obv, but otherwise you can checkout that hash
Oh, thanks. Only return to this version helped me to fix problem on Linux with Alacritty!
"jackMort/ChatGPT.nvim", commit = '8820b99c', -- March 6th 2023, before submit issue config = function() require("chatgpt").setup({ ...
Temporary fix, setting it back to a previous commit - need to run :PackerSync after making this change in plugins.lua - this only applies if you are using packer obv, but otherwise you can checkout that hash
Thanks, this fixes the submit issue. However, now multi-line prompts seem no longer possible, because every enter automatically submits.
"jackMort/ChatGPT.nvim", commit = '8820b99c', -- March 6th 2023, before submit issue config = function() require("chatgpt").setup({ ...
Temporary fix, setting it back to a previous commit - need to run :PackerSync after making this change in plugins.lua - this only applies if you are using packer obv, but otherwise you can checkout that hash
Thanks, this fixes the submit issue. However, now multi-line prompts seem no longer possible, because every enter automatically submits.
Yes, because you checked out a commit hash before that was even a feature. Did you try changing the keybinding to something like...
submit = '<C-t>',
in ...
keymaps = {
close = { "<C-c>", "<Esc>" },
yank_last = "<C-y>",
yank_last_code = "<C-k>",
scroll_up = "<C-u>",
scroll_down = "<C-d>",
toggle_settings = "<C-o>",
new_session = "<C-n>",
cycle_windows = "<Tab>",
-- in the Sessions pane
select_session = "<Space>",
rename_session = "r",
delete_session = "d",
submit = '<C-t>',
}
same
this happen on my linux fedora machine, on mac there is no such issue.
this happened for me on mac, specifying commit worked but would like to be able to use multiline
Same permanent issue here on WezTerm.
-
C-Enter
adds a new line.
Changing the Submit binding to C-t
works!
If you're using Alacritty, try adding this to your config file:
key_bindings: # https://stackoverflow.com/a/42461580 - { key: Return, mods: Control, chars: "\x1b[13;5u" }
For the whole set:
key_bindings: # https://stackoverflow.com/a/42461580 - { key: Return, mods: Shift, chars: "\x1b[13;2u" } - { key: Return, mods: Control, chars: "\x1b[13;5u" } - { key: Space, mods: Shift, chars: "\x1b[32;2u" } - { key: Space, mods: Control, chars: "\x1b[32;5u" } # NOTE: This is an edge case and might not work.
Hey guys, I've tried those mappings which I already had on my simple-terminal (st) emulator and I couldn't make it works.
For example I have this on my config.def.h
:
neither using other bindings like <C-s>
, <C-a>
, <C-t>
works. It did work on xterm and kitty but didn't on alacritty and st. As st is my default term, if anyone could make it works on it, please let me know. ;-)
Before I said that it works on xterm and kitty but it doesn't if I'm inside a tmux session :disappointed:
It tooks me to read many SO questions but finally I got with the correct key:
- https://unix.stackexchange.com/questions/536352/ctrl-enter-shift-enter-and-enter-are-interpreted-as-the-same-key
- https://unix.stackexchange.com/questions/76566/where-do-i-find-a-list-of-terminal-key-codes-to-remap-shortcuts-in-bash
You can use showkey -a
and then press you key combination to see the key code mapped, in my case:
$ showkey -a
Press any keys - Ctrl-D will terminate this program
^M 13 0015 0x0d
^D 4 0004 0x04
So, I've set the submit keybind to <C-m>
and it works as expected in all terminals.
use({
"jackMort/ChatGPT.nvim",
config = function()
require("chatgpt").setup({
keymaps = {
submit = "<C-m>"
}
})
end,
requires = {
"MunifTanjim/nui.nvim",
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim"
}
})
Hope this helps :-)
the default configuration become:
local defaults = {
yank_register = "+",
edit_with_instructions = {
diff = false,
keymaps = {
accept = "<C-y>",
toggle_diff = "<C-d>",
toggle_settings = "<C-o>",
cycle_windows = "<Tab>",
use_output_as_input = "<C-i>",
},
},
chat = {
welcome_message = WELCOME_MESSAGE,
loading_text = "Loading, please wait ...",
question_sign = "", -- 🙂
answer_sign = "ﮧ", -- 🤖
max_line_length = 120,
sessions_window = {
border = {
style = "rounded",
text = {
top = " Sessions ",
},
},
win_options = {
winhighlight = "Normal:Normal,FloatBorder:FloatBorder",
},
},
keymaps = {
close = { "<C-c>" },
yank_last = "<C-y>",
yank_last_code = "<C-k>",
scroll_up = "<C-u>",
scroll_down = "<C-d>",
toggle_settings = "<C-o>",
new_session = "<C-n>",
cycle_windows = "<Tab>",
select_session = "<Space>",
rename_session = "r",
delete_session = "d",
},
},
popup_layout = {
relative = "editor",
position = "50%",
size = {
height = "80%",
width = "80%",
},
},
popup_window = {
filetype = "chatgpt",
border = {
highlight = "FloatBorder",
style = "rounded",
text = {
top = " ChatGPT ",
},
},
win_options = {
winhighlight = "Normal:Normal,FloatBorder:FloatBorder",
},
},
popup_input = {
prompt = " ",
border = {
highlight = "FloatBorder",
style = "rounded",
text = {
top_align = "center",
top = " Prompt ",
},
},
win_options = {
winhighlight = "Normal:Normal,FloatBorder:FloatBorder",
},
submit = "<C-Enter>",
},
settings_window = {
border = {
style = "rounded",
text = {
top = " Settings ",
},
},
win_options = {
winhighlight = "Normal:Normal,FloatBorder:FloatBorder",
},
},
openai_params = {
model = "gpt-3.5-turbo",
frequency_penalty = 0,
presence_penalty = 0,
max_tokens = 300,
temperature = 0,
top_p = 1,
n = 1,
},
openai_edit_params = {
model = "code-davinci-edit-001",
temperature = 0,
top_p = 1,
n = 1,
},
actions_paths = {},
predefined_chat_gpt_prompts = "https://raw.githubusercontent.com/f/awesome-chatgpt-prompts/main/prompts.csv",
}
Hence, if you want to remap submit
you need:
{
"jackMort/ChatGPT.nvim",
dependencies = {
"MunifTanjim/nui.nvim",
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim",
},
config = function()
require("chatgpt").setup({
chat = {
keymaps = {
close = { "jk", "kj", "<Esc>" },
yank_last = "<C-y>",
scroll_up = "<C-u>",
scroll_down = "<C-d>",
toggle_settings = "<C-o>",
new_session = "<C-n>",
cycle_windows = "<Tab>",
},
},
popup_input = {
submit = "<C-s>",
},
})
end,
}
Before I said that it works on xterm and kitty but it doesn't if I'm inside a tmux session disappointed
Same, but seems to work outside of tmux. wezterm here
I was using <C-t> for submission, and that suddenly stopped working. Looks like some configs have shifted since I last updated. If things are suddenly broken for you, check the example config and see if the table keys have changed since you last configured.
This https://github.com/tmux/tmux/wiki/Modifier-Keys#extended-keys resolved for me, without rebind the <C-Enter>
.