Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Dec 25, 2023

Conversation

wookayin
Copy link
Contributor

@wookayin wookayin commented Dec 25, 2023

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.

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
Copy link
Owner

Thanks!

@wookayin wookayin deleted the fix-hl branch March 7, 2024 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants