gsuuon / model.nvim

Neovim plugin for interacting with LLM's and building editor integrated prompts.
MIT License
293 stars 21 forks source link

fix: notify when in lua loop callback #48

Closed somnam closed 6 months ago

somnam commented 6 months ago

I frequently got following error from request handlers or util.show / util.eshow :

Press ENTER or type command to continue
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'
        ...local/share/nvim/lazy/model.nvim/lua/model/util/init.lua:16: in function 'show'
        ...local/share/nvim/lazy/model.nvim/lua/model/util/init.lua:20: in function 'show'

It looks that when using the provided async(function(wait, resolve) helper one needs to schedule displaying the notification instead of notifying directly in the callback.