ChatGPT.nvim icon indicating copy to clipboard operation
ChatGPT.nvim copied to clipboard

Can't submit prompt

Open liketoeatcheese opened this issue 1 year ago • 11 comments

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: image

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",
		},
	})

liketoeatcheese avatar Mar 15 '23 22:03 liketoeatcheese

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.

kalkin avatar Mar 15 '23 22:03 kalkin

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

liketoeatcheese avatar Mar 15 '23 22:03 liketoeatcheese

It is happening the same to me, Enter or C-Enter just adds a new line, it won't submit my request

darvein avatar Mar 16 '23 01:03 darvein

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"
    }
  })

shutils avatar Mar 16 '23 01:03 shutils

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

liketoeatcheese avatar Mar 16 '23 01:03 liketoeatcheese

Cant't get the above to work. Nightly build. Kitty terminal.

SibLiant avatar Mar 16 '23 15:03 SibLiant

try to remap the submit to something else, provide your config if issue still occurs

jackMort avatar Mar 16 '23 16:03 jackMort

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.

zArubaru avatar Mar 17 '23 12:03 zArubaru

Remapping to <C-t> works for me. On Ubuntu using Kitty terminal.

raphaklaus avatar Mar 17 '23 23:03 raphaklaus

None of the above work for me, won't submit on os X Terminal, the mapping doesn't seem to apply at all.

ashot avatar Mar 18 '23 22:03 ashot

"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

ben-wall avatar Mar 19 '23 07:03 ben-wall

"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!

dmytrodubinin avatar Mar 22 '23 14:03 dmytrodubinin

"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.

gstokkink avatar Mar 24 '23 12:03 gstokkink

"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>',
          }

ben-wall avatar Mar 24 '23 21:03 ben-wall

same

qvieth avatar Mar 30 '23 06:03 qvieth

this happen on my linux fedora machine, on mac there is no such issue.

qvieth avatar Mar 30 '23 23:03 qvieth

this happened for me on mac, specifying commit worked but would like to be able to use multiline

wstewarttennes avatar Mar 31 '23 23:03 wstewarttennes

Same permanent issue here on WezTerm.

  • C-Enter adds a new line.

Changing the Submit binding to C-t works!

lpanebr avatar Apr 03 '23 18:04 lpanebr

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: image

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. ;-)

mmngreco avatar Apr 05 '23 15:04 mmngreco

Before I said that it works on xterm and kitty but it doesn't if I'm inside a tmux session :disappointed:

mmngreco avatar Apr 11 '23 10:04 mmngreco

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 :-)

mmngreco avatar Apr 11 '23 12:04 mmngreco

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,
    }

cauliyang avatar Apr 12 '23 06:04 cauliyang

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

cybermelons avatar Apr 14 '23 17:04 cybermelons

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.

kagbodji avatar Apr 15 '23 22:04 kagbodji

This https://github.com/tmux/tmux/wiki/Modifier-Keys#extended-keys resolved for me, without rebind the <C-Enter>.

GiuseppeMP avatar Jul 22 '23 18:07 GiuseppeMP