kevinhwang91 / nvim-ufo

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

Error when call `setFoldVirtTextHandler` #44

Closed anuvyklack closed 2 years ago

anuvyklack commented 2 years ago

Neovim version (nvim -v | head -n1)

NVIM 0.7.2

Operating system/version

Fedora 36

How to reproduce the issue

Add next line inside ~/.config/nvim/after/ftplugin/lua.lua

require('ufo').setFoldVirtTextHandler(nil, handler)

Expected behavior

no error

Actual behavior

E5113: Error while calling lua chunk: ...re/nvim/site/pack/packer/start/ufo/lua/ufo/decorator.lua:180: 
attempt to index field 'virtTextHandlers' (a nil value)
stack traceback:
        ...re/nvim/site/pack/packer/start/ufo/lua/ufo/decorator.lua:180: in function 'setVirtTextHandler'
        ....local/share/nvim/site/pack/packer/start/ufo/lua/ufo.lua:150: in function 'setFoldVirtTextHandler'
vonPB commented 2 years ago

can not reproduce on nvim nightly, Win 10. There is the appropriate check, so not sure why its failing for you. https://github.com/kevinhwang91/nvim-ufo/blob/752b026725a6da7d03588b004acf86b45c5526dc/lua/ufo/decorator.lua#L179

anuvyklack commented 2 years ago

I still have this problem.

E5113: Error while calling lua chunk: ...re/nvim/site/pack/packer/start/ufo/lua/ufo/decorator.lua:180:
attempt to index field 'virtTextHandlers' (a nil value)
stack traceback:
        ...re/nvim/site/pack/packer/start/ufo/lua/ufo/decorator.lua:180: in function 'setVirtTextHandler'
        ....local/share/nvim/site/pack/packer/start/ufo/lua/ufo.lua:150: in function 'setFoldVirtTextHandler'
        /home/anuvyklack/.config/nvim/after/ftplugin/lua.lua:111: in main chunk

even when I use

local bufnr = vim.api.nvim_get_current_buf()
require('ufo').setFoldVirtTextHandler(bufnr, lua_ts_handler)
kevinhwang91 commented 2 years ago

Use a mini config and solve it yourself. I guess your Lua ENV has been hacked.

anuvyklack commented 2 years ago

I found the problem. Next line in my init.vim causes it

syntax enable