Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors using .accept API #278

Open
ldelossa opened this issue Mar 1, 2024 · 2 comments
Open

Errors using .accept API #278

ldelossa opened this issue Mar 1, 2024 · 2 comments

Comments

@ldelossa
Copy link

ldelossa commented Mar 1, 2024

Hello.

I'm trying to use Copilot in a 'super-tab' fashion like this:

local keys = {
  ['tab']        = vim.api.nvim_replace_termcodes('<Tab>', true, true, true),
  ['ctrl-y']     = vim.api.nvim_replace_termcodes('<C-y>', true, true, true),
  ['ctrl-tab']   = vim.api.nvim_replace_termcodes('<C-Tab>', true, true, true),
}
_G.tab_action = function()
  if vim.fn.pumvisible() ~= 0 then
    return keys['ctrl-y']
	elseif require("copilot.suggestion").is_visible() then
    require("copilot.suggestion").accept()
		return
  else
    return keys['tab']
  end
end
vim.keymap.set('i', '<Tab>', 'v:lua._G.tab_action()', { expr = true })

However, whenever I try to use tab to fill in a suggestion I get the following Neovim here:

E5108: Error executing lua /usr/share/nvim/runtime/lua/vim/lsp/util.lua:515: E565: Not allowed to change text or change window                                                                                    
stack traceback:                                                                                                                                                                                                  
        [C]: in function 'nvim_buf_set_text'                                                                                                                                                                      
        /usr/share/nvim/runtime/lua/vim/lsp/util.lua:515: in function 'apply_text_edits'                                                                                                                          
        ...ite/pack/deps/opt/copilot.lua/lua/copilot/suggestion.lua:487: in function 'accept'                                                                                                                     
        /home/louis/git/dotfiles/config/nvim/init.lua:503: in function </home/louis/git/dotfiles/config/nvim/init.lua:499>  
@dinhmai74
Copy link

same here

@vinicius507
Copy link

Same here. I'm using neovim 0.9.4,.
It only happens when using require("copilot.suggestion").accept, if I use require("copilot.suggestion").accept_word it works.

Here's a stack trace:

E5108: Error executing lua: ...-unwrapped-0.9.4/share/nvim/runtime/lua/vim/lsp/util.lua:501: Failed to save undo information
stack traceback:
	[C]: in function 'nvim_buf_set_text'
	...-unwrapped-0.9.4/share/nvim/runtime/lua/vim/lsp/util.lua:501: in function 'apply_text_edits'
	...l/share/nvim/lazy/copilot.lua/lua/copilot/suggestion.lua:487: in function 'accept'
	/home/vini/.config/nvim/lua/plugins/coding.lua:10: in function </home/vini/.config/nvim/lua/plugins/coding.lua:8>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants