zbirenbaum / copilot.lua

Fully featured & enhanced replacement for copilot.vim complete with API for interacting with Github Copilot
MIT License
2.45k stars 67 forks source link

Lost keymaps for InsertLeave #181

Closed cmac4603 closed 1 year ago

cmac4603 commented 1 year ago

After installing copilot.lua, I've lost my custom keymappings for InsertLeave, and it seems I've lost <Esc> in particular for leaving insert mode:

I haven't written this anywhere in my copilot config that I can see, and I can fix all of these by changing <Esc> to <C-c> in my mappings, but I was wondering if anyone could shed some light as to why <Esc> has stopped working? Reading the docs there wasn't any mention of this.

return {
  "zbirenbaum/copilot.lua",
  cmd = "Copilot",
  event = "InsertEnter",
  config = function()
    require("copilot").setup({
      panel = {
        enabled = true,
        auto_refresh = true,
        keymap = {
          jump_prev = "[[",
          jump_next = "]]",
          accept = "<CR>",
          refresh = "gr",
          open = "<M-CR>"
        },
        layout = {
          position = "bottom", -- | top | left | right
          ratio = 0.4
        },
      },
      filetypes = {
        yaml = true,
        markdown = true,
        help = true,
        gitcommit = true,
        gitrebase = true,
        qf = true,
        hgcommit = true,
        svn = true,
        cvs = true,
        ["."] = true,
      },
      suggestion = {
        enabled = true,
        auto_trigger = false,
        debounce = 75,
        keymap = {
          accept = "<c-j>",
          next = "<c-]>",
          prev = "<c-[>",
          dismiss = "jk",
        },
      },
    })
  end,
}
cmac4603 commented 1 year ago

Nvm, after hours looking then posting this, realised it was because I was remapping CTRL-[ which in neovim is equivalent to <Esc>. Going to get more coffee now.

choznerol commented 12 months ago

... I was remapping CTRL-[ which in neovim is equivalent to <Esc>.

Thanks so much for sharing this! The default <M-[> outputs a for me on Mac so I changed it to <C-[>. I was so confused when <Esc> stop working 😅.