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

fix(treesitter): fix errors when getting hlId on nvim 0.10.x #188

Closed wookayin closed 6 months ago

wookayin commented 6 months ago

Since neovim 0.10.x 2498747a (2023/12/20), hl_cache (which is private) is no longer made of a metatable. This results in following errors:

E5108: Error executing lua: table index is nil
stack traceback:
        [C]: in function 'rawset'
        .../nvim-ufo/lua/ufo/highlight.lua:31: in function '__index'
        .../nvim-ufo/lua/ufo/render/treesitter.lua:54: in function 'fn'
        $VIMRUNTIME/lua/vim/treesitter/languagetree.lua:489: in function 'for_each_tree'
        $VIMRUNTIME/lua/vim/treesitter/languagetree.lua:493: in function 'for_each_tree'
        .../nvim-ufo/lua/ufo/render/treesitter.lua:19: in function 'getHighlightsByRange'
        .../nvim-ufo/lua/ufo/render/init.lua:132: in function 'mapHighlightLimitByRange'
        .../nvim-ufo/lua/ufo/preview/init.lua:291: in function 'peekFoldedLinesUnderCursor'

A temporary fix is to use query:get_hl_from_capture(), which is also an private API, but this prevents the error on nvim nightly.

kevinhwang91 commented 6 months ago

Thanks!