hrsh7th / nvim-cmp

A completion plugin for neovim coded in Lua.
MIT License
8.16k stars 407 forks source link

fix(feedkeys): resolve issue with some copilot completions #1981

Closed tris203 closed 4 months ago

tris203 commented 4 months ago

This seems to fix #1560 in my limited testing. It would be great if anyone else can test it and see if any other issues arise. and https://github.com/zbirenbaum/copilot-cmp/issues/79

At the very least, we should include the pcall to stop it from crashing cmp entirely in the event of a bad completion,

This is required after neovim deprecations here: https://github.com/neovim/neovim/pull/24350

eli-front commented 4 months ago

This seems to reduce the number of times I see this error, but I still got a .../.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:394: Invalid 'start_col': out of range when using this PR. Struggling to reproduce consistently, but will post here if I figure something out

tris203 commented 4 months ago

This seems to reduce the number of times I see this error, but I still got a .../.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:394: Invalid 'start_col': out of range when using this PR. Struggling to reproduce consistently, but will post here if I figure something out

Interesting. What language are you writing? I also assume with this PR, that it didn't crash cmp completely? so you should be able to undo and reproduce the error over and over again

eli-front commented 4 months ago

This seems to reduce the number of times I see this error, but I still got a .../.local/share/nvim/lazy/nvim-cmp/lua/cmp/core.lua:394: Invalid 'start_col': out of range when using this PR. Struggling to reproduce consistently, but will post here if I figure something out

Interesting. What language are you writing? I also assume with this PR, that it didn't crash cmp completely? so you should be able to undo and reproduce the error over and over again

I was using typescript. Here's my nvim-cmp config

return {
  "https://github.com/tris203/nvim-cmp",
  commit = "ab4cb2a3f5c439c5a4b4e92f92b50df0164f7713",
  event = "InsertEnter",
  config = function()
    local cmp = require("cmp")
    cmp.setup({
      sources = {
        { name = "copilot" },
        { name = "nvim_lsp" },
        { name = "luasnip" }, -- snippets
        { name = "buffer" },  -- text within current buffer
        { name = "path" },    -- file system paths
      },
      mapping = cmp.mapping.preset.insert({
        ['<CR>'] = cmp.mapping.confirm({
          behavior = cmp.ConfirmBehavior.Replace,
          select = false,
        }),
        ['<C-j>'] = cmp.mapping.select_next_item(),
        ['<C-k>'] = cmp.mapping.select_prev_item(),
      })
    })
  end,
}

& my copilot confi

return {
  {
    "zbirenbaum/copilot.lua",
    cmd = "Copilot",
    event = "InsertEnter",
    config = function()
      require("copilot").setup({
        suggestion = { enabled = false },
        panel = { enabled = false },
        filetypes = {
          markdown = true,
          help = true,
          toml = true,
        },
      })
    end,
  },
  {
    "zbirenbaum/copilot-cmp",
    config = function()
      require("copilot_cmp").setup()
    end
  }
}