kevinhwang91 / nvim-ufo

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

Namespace conflict with notomo/promise.nvim #8

Open romgrk opened 2 years ago

romgrk commented 2 years ago

Neovim version (nvim -v | head -n1)

0.8.0-dev

Operating system/version

archlinux

How to reproduce the issue

  1. Install the plugin, including the minimal configuration, with coc-nvim
  2. Start neovim

Expected behavior

Plugin works

Actual behavior

There are a few issues, first one is:

Error executing vim.schedule lua callback: unhandled promise rejection: { "/home/romgrk/.config/nvim/bundle/nvim-ufo/lua/ufo/utils.lua:110: attempt to call a table value" }
stack traceback:
        [C]: in function 'error'
        ...rk/.config/nvim/bundle/promise.nvim/lua/promise/init.lua:65: in function <...rk/.config/nvim/bundle/promise.nvim/lua/promise/init.lua:63>

It is solved by add require('promise').new(...) here: https://github.com/kevinhwang91/nvim-ufo/blob/cf7dc7fa196dbb835a1b8bbc5d7c5f6d786f41ee/lua/ufo/utils.lua#L104

The second issue (after fixing the one above) is:

Error detected while processing BufWritePost Autocommands for "*":
E5108: Error executing lua /home/romgrk/.config/nvim/bundle/nvim-ufo/lua/ufo/fold.lua:201: attempt to call method 'thenCall' (a nil value)
stack traceback:
        /home/romgrk/.config/nvim/bundle/nvim-ufo/lua/ufo/fold.lua:201: in function 'listener'
        /home/romgrk/.config/nvim/bundle/nvim-ufo/lua/ufo/event.lua:52: in function 'emit'
romgrk commented 2 years ago

Forget all of the above. The root cause is a namespace conflict with https://github.com/notomo/promise.nvim. Both that plugin and your promise-async try to use the require('promise') namespace in lua.

kevinhwang91 commented 2 years ago

Even though I have no idea to fix it, please show path about promise-async and promise.nvim.

romgrk commented 2 years ago

Both installed with vim-plug. If you see on that repo, they use ./lua/promise.lua as well. You'll need to decide by a duel who keeps the name. Ping @notomo.

The best solution is probably to upstream either one of these into neovim.

kevinhwang91 commented 2 years ago

I think ufo can add post-installation to install promise-async inside the plugin, depending on the user who has a promise and async module outside ufo.

notomo commented 2 years ago

@romgrk Hi. I don't expect notomo/promise.nvim to be installed directly. You can use my promise.nvim by embedding in your plugins namespace.

ref: https://github.com/notomo/promise.nvim/blob/10b86664130f9668f0fa6549bda660794417aaf7/README.md#L4-L4

Mainly used by embedding lua/promise/init.lua in plugins.

example: https://github.com/notomo/optpack.nvim/blob/119239f099f72c4dd6949862738991593554fee5/lua/optpack/lib/git.lua#L1-L1