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

Autocompleting suggestion broken after latest Neovim update #273

Closed danielpost closed 4 months ago

danielpost commented 4 months ago

After updating Neovim, I'm getting the following error when trying to autocomplete:

E5108: Error executing lua: ...vim/HEAD-0fcbda5/share/nvim/runtime/lua/vim/lsp/util.lua:423: Explicit buffer number is required
stack traceback:
    [C]: in function 'assert'
    ...vim/HEAD-0fcbda5/share/nvim/runtime/lua/vim/lsp/util.lua:423: in function 'apply_text_edits'
    ...l/share/nvim/lazy/copilot.lua/lua/copilot/suggestion.lua:487: in function <...l/share/nvim/lazy/copilot.lua/lua/copilot/suggestion.lua:445>

It is almost definitely related to this change: https://github.com/neovim/neovim/pull/27614, and I think the fix would be to pass the current buffer here, but I don't know enough about Lua to be 100% sure.

siblanco commented 4 months ago

hi, you are right, for a quickfix, do this

  vim.lsp.util.apply_text_edits({ { range = range, newText = newText } }, vim.api.nvim_get_current_buf(), "utf-16")
GitMurf commented 4 months ago

I am getting the same problem on Windows 11 fyi. And I can confirm the fix provided by @siblanco works so thank you both!

fgheng commented 4 months ago

I am getting the same problem on Windows 11 fyi. And I can confirm the fix provided by @siblanco works so thank you both!

hello, where add this, I add it to lazy config:

config = function()
  vim.lsp.util.apply_text_edits({ { range = range, newText = newText } }, vim.api.nvim_get_current_buf(), "utf-16")
end

where can I take the params range and newText