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

Highlighting break when disable returns false #31

Closed
Nsidorenco opened this issue Aug 29, 2024 · 1 comment · Fixed by #32
Closed

Highlighting break when disable returns false #31

Nsidorenco opened this issue Aug 29, 2024 · 1 comment · Fixed by #32

Comments

@Nsidorenco
Copy link
Contributor

First of all, thank you for this really cool project!
When trying out the new feature to conditionally disable highlights I have run into some problems:

Configuration to reproduce

vim.g.rocks_nvim = {
    treesitter = {
        auto_highlight = "all",
        auto_install = "prompt",
        disable = function (_, _) return false end
    },
}

Result

Entering any buffer produces the following error:

Error detected while processing BufReadPost Autocommands for "*":                                                                                                                                           
Error executing lua callback: ...neovim-unwrapped-nightly/share/nvim/runtime/filetype.lua:36: BufReadPost Autocommands for "*"..FileType Autocommands for "lua"..FileType Autocommands for "lua"..FileType A
utocommands for "*": Vim(append):Error executing lua callback: .../nvim/rocks/rocks_rtp/lua/rocks_treesitter/highlight.lua:142: attempt to index field 'disable' (a function value)  

Expected result

Should highlight file with no problem.

I think it might be related to the associativity of operators in:

local disable = type(config.disable) == "function" and config.disable(lang, bufnr)
                or config.disable[filetype]

where the or config.disable[filetype] ends up always being executed.

@mrcjkb
Copy link
Member

mrcjkb commented Aug 29, 2024

thanks for reporting 🙏

that was a dumb mistake on my end.
fix implemented in 63b711c

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 a pull request may close this issue.

2 participants