nvim-neorocks / rocks-treesitter.nvim

A "just works" tree-sitter setup for rocks.nvim!
GNU General Public License v3.0
36 stars 4 forks source link

Highlighting break when disable returns false #31

Closed Nsidorenco closed 2 months ago

Nsidorenco commented 2 months ago

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 commented 2 months ago

thanks for reporting 🙏

that was a dumb mistake on my end. fix implemented in https://github.com/nvim-neorocks/rocks-treesitter.nvim/commit/63b711c6d0d10db80ff8550cfe840bd7d2200967