Exafunction / codeium.nvim

A native neovim extension for Codeium
MIT License
644 stars 50 forks source link

[bug] vim.notify call issued an error. #5

Closed towry closed 1 year ago

towry commented 1 year ago
Error executing luv callback:                                                                          
vim/_editor.lua:0: E5560: nvim_echo must not be called in a lua loop callback                          
stack traceback:                                                                                       
        [C]: in function 'nvim_echo'                                                                   
        vim/_editor.lua: in function 'notify'                                                          
        ...ocal/share/nvim/lazy/codeium.nvim/lua/codeium/update.lua:72: in function 'unpack'           
        ...ocal/share/nvim/lazy/codeium.nvim/lua/codeium/update.lua:111: in function '_user_on_exit'   
        .../.local/share/nvim/lazy/plenary.nvim/lua/plenary/job.lua:240: in function '_shutdown'       
        .../.local/share/nvim/lazy/plenary.nvim/lua/plenary/job.lua:46: in function <.../.local/share/n
vim/lazy/plenary.nvim/lua/plenary/job.lua:37>  

https://github.com/jcdickinson/codeium.nvim/blob/a940a99e1e168515edea3964c15a4a350f2414db/lua/codeium/update.lua#L72

NVIM v0.9.0-dev-3318+g9b1112cf4-dirty                                                                  
Build type: Release                                                                                    
LuaJIT 2.1.0-beta3                                                                                     
Compiled by towry@towryDeMpb.local                                                                     

Features: +acl +iconv +tui
towry commented 1 year ago

Possible solution: https://github.com/neovim/neovim/pull/21288/files

update:

local function notify(msg, level)
    if vim.in_fast_event() then
      vim.schedule(function()
        vim.notify(msg, level)
      end)
    else
      vim.notify(msg, level)
    end
  end

Works, tested on my local repo.

jcdickinson commented 1 year ago

Thanks for the bug report! Please let me know if this latest changes fix this.