Closed akinsho closed 3 years ago
~ Yeah just change enabled
from true
to a table of languages you want to enable it for (just like the main nvim-treesitter plugin) ~
@p00f I just tried setting enable = {"dart"}
as an example but that doesn't work lua still shows rainbow parentheses 🤔 the README
says the key is enable
not enabled
but I tried using enabled
and that just turns the plugin off completely
It is enable
indeed. Also, sorry but there's only enable = true
and disable = list of languages
@p00f thanks that works, shame it works in that order since to only enable it for a few languages I'd end up having to list all available languages except the one I want 😅 . Anyway thanks for the help.
I came here for the same exact request as @akinsho, it will be great @p00f if there is a way to enable the plugin only for some langauges.
I don't want to implement this on the module side, can you open an issue on the main nvim-treesitter repo and see? If they don't want to then I'll try doing it
@ahmedelgabri
I don't want to implement this on the module side, can you open an issue on the main nvim-treesitter repo and see? If they don't want to then I'll try doing it
@ahmedelgabri
Unless I'm missing something why is it needed to be added to treesitter? I actually don't see that useful on the treesitter side but I see it useful here, the reason is I might want treesitter support for more languages than I'd like rainbow parentheses support. Technically I want support for treesitter for everything, but rainbow parentheses support only for lisp like languages.
This is an not a standalone plugin but an nvim-treesitter module generated from the module template given by nvim-treesitter:
Enabling and disabling is controlled by the main nvim-treesitter plugin: https://github.com/nvim-treesitter/nvim-treesitter#modules
If they implement this on their side then you can do it to any module given here
https://github.com/nvim-treesitter/nvim-treesitter/wiki/Extra-modules-and-plugins#extra-modules
note that 3 out of the 6 modules mentioned there are outside the nvim-treesitter organization
I think I found a way around this limitation without maintaining a full table of disabled languages.
local parsers = require("nvim-treesitter.parsers")
rainbow = {
enable = true,
-- Enable only for lisp like languages
disable = vim.tbl_filter(
function(p)
return p ~= "clojure" and p ~= "commonlisp" and p ~= "fennel" and p ~= "query"
end,
parsers.available_parsers()
)
},
Neat! If that list grows larger you can use
local enabled_list = {"clojure", "fennel", "commonlisp", "query", ...}
rainbow = {
enable = true,
-- Enable only for lisp like languages
disable = vim.tbl_filter(
function(p)
local disable = true
for _, lang in pairs(enabled_list) do
if p==lang then disable = false end
end
return disable
end,
parsers.available_parsers()
)
},
Should be a part of the documentation imho.
It would be nice if enable
could either be true
or a list of languages. The vim.tbl_filter
snippet isn't hmm... ergonomic.
Hi 👋🏿 thanks for your work on this plugin.
I've just moved over from
luochen1990
's plugin and I'm wondering if it's possible to enable this plugin for only a few filetypes primarily since there are only a few languages I use that tend to get a little unmanageable with their parens (e.g. lisps) but for things likelua
I don't really need this functionality.