zbirenbaum / copilot.lua

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

Accept suggestion results in Range too large error #244

Open RobinClowers opened 7 months ago

RobinClowers commented 7 months ago

I just set this plugin up, and tried the simplest thing.

function sum(a: number, b: number) {
    // here I invoked the next function with <M-]>
}

It generated the suggestion just fine, but when I tried to accept it with <M-l>, I get this error:

E5108: Error executing lua: Vim:E945: Range too large in character class
stack traceback:
        [C]: in function 'substitute'
        ...ocal/share/nvim/plugged/copilot.lua/lua/copilot/util.lua:300: in function 'strutf16len'
        ...hare/nvim/plugged/copilot.lua/lua/copilot/suggestion.lua:463: in function 'fn'
        ...hare/nvim/plugged/copilot.lua/lua/copilot/suggestion.lua:32: in function 'with_client'
        ...hare/nvim/plugged/copilot.lua/lua/copilot/suggestion.lua:460: in function <...hare/nvim/plugged/copilot.lua/lua/copilot/suggestion.lua:445>

I suspect I'm doing something wrong here, since this plugin is working for other folks. I'm using vim-plug and calling setup from a vimrc file, like this:

call plug#begin(has('nvim') ? stdpath('data') . '/plugged' : '~/.vim/plugged')
" ... other plugins

Plug 'zbirenbaum/copilot.lua'

call plug#end()

" Initialize github copilot
lua require('copilot').setup({})
MunifTanjim commented 7 months ago

What's the output of :Copilot version?

RobinClowers commented 7 months ago
Neovim 0.9.1
copilot.vim 1.12.1
copilot.lua 3665ed0f3ef3ad68673df7195789d134d0d1fdb0
copilot/dist/agent.js 1.138.0
Node.js 18.17.1
RobinClowers commented 7 months ago

FYI I just upgraded neovim to 0.9.4 and I still get the same result.

mr-mustash commented 6 months ago

May be related, but I'm getting this error happens to me whenever I try to accept a suggestion:

[Copilot] failed to notify_accepted for:                         kill = "<C-c>",
Error: Vim:E945: Range too large in character class

The text is still entered into the buffer, but that error comes up every time I accept that suggestion.

Here is my version info:

Neovim 0.9.4
copilot.vim 1.12.1
copilot.lua 38a41d0d78f8823cc144c99784528b9a68bdd608
copilot/dist/agent.js 1.138.0
Node.js 21.4.0

And my configuration with lazy.nvim:

return {
    {
        "zbirenbaum/copilot.lua",
        cmd = "Copilot",
        event = "InsertEnter",
        config = function ()
            require('copilot').setup({
                  panel = {
                    enabled = false,
                },
                suggestion = {
                    enabled = true,
                    auto_trigger = true,
                    debounce = 75,
                    keymap = {
                        accept = "<C-k>",
                    },
                },
                filetypes = {
                    commit = false,
                    cvs = false,
                    git = false,
                    gitcommit = false,
                    gitrebase = false,
                    gitsendmail = false,
                    help = false,
                    hgcommit = false,
                    markdown = false,
                    md = false,
                    mkd = false,
                    svn = false,
                    tex = false,
                    text = false,
                    yaml = false,
                },
            })
        end
    }
}
sakithb commented 5 months ago

Same here

Neovim 0.9.5
copilot.vim 1.13.0
copilot.lua b03617a6dc4bc88b65ab5deac1631da9a9c2dcaf
copilot/dist/agent.js 1.141.0
Node.js 21.3.0