kevinhwang91 / nvim-ufo

Not UFO in the sky, but an ultra fold in Neovim.
BSD 3-Clause "New" or "Revised" License
2.16k stars 37 forks source link

`UnhandledPromiseRejection` on `InsertLeave` event #158

Closed Per48edjes closed 9 months ago

Per48edjes commented 9 months ago

Neovim version (nvim -v | head -n1)

NVIM v0.9.0

Operating system/version

macOS 13.1

How to reproduce the issue

  1. Begin developing with Haskell language server
  2. Write ill-formed Haskell in insert mode and try to escape to normal mode
  3. Observe error

Here's the output from :verbose autocmd InsertLeave:

--- Autocommands ---
NullLs  InsertLeave
    *         <Lua 546: ~/.local/share/nvim/lazy/null-ls.nvim/lua/null-ls/init.lua:48>
        Last set from Lua
copilot.suggestion  InsertLeave
    *         <Lua 585: ~/.local/share/nvim/lazy/copilot.lua/lua/copilot/suggestion.lua:528> [[copilot] (suggestion) in
sert leave]
        Last set from Lua
___cmp___  InsertLeave
    *         <Lua 612: ~/.local/share/nvim/lazy/nvim-cmp/lua/cmp/utils/autocmd.lua:22> [nvim-cmp: autocmd: InsertLeave
]
        Last set from Lua
luasnip  InsertLeave
    *         <Lua 666: ~/.local/share/nvim/lazy/LuaSnip/lua/luasnip/init.lua:442>
        Last set from Lua
lsp_codelens_refresh  InsertLeave
    <buffer=1>
              <Lua 921: ~/.config/nvim/lua/astronvim/utils/lsp.lua:163> [Refresh codelens]
        Last set from Lua
haskell-tools-code-lens  InsertLeave
    <buffer=1>
              <Lua 1100: ~/.local/share/nvim/lazy/haskell-tools.nvim/lua/haskell-tools/lsp.lua:147>
        Last set from Lua
Ufo  InsertLeave
    *         lua require('ufo.lib.event'):emit('InsertLeave', vim.api.nvim_get_current_buf())
        Last set from Lua

Running that last command, :lua require('ufo.lib.event'):emit('InsertLeave', vim.api.nvim_get_current_buf()), reproduces the error.

Expected behavior

No error. When I UfoDisable (or UfoDisableFold) on a buffer that's raising this error, this error ceases to be raised.

Actual behavior

Here is a screencap with the bug reproduced:

image

I originally thought this might've been an issue with haskell-tools.nvim, but @mrcjkb 's investigation seems to point to this autocommand -- see mrcjkb/haskell-tools.nvim#251 for a more detailed discussion.