From fdfbb5c1bf7ad863eb662fdf2e7fb39ed8b1e707 Mon Sep 17 00:00:00 2001 From: echasnovski Date: Sun, 31 Jan 2021 13:09:25 +0200 Subject: Implement `TSToggleAll`. --- lua/nvim-treesitter/configs.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'lua/nvim-treesitter/configs.lua') diff --git a/lua/nvim-treesitter/configs.lua b/lua/nvim-treesitter/configs.lua index 9f7627a0..4b815dd3 100644 --- a/lua/nvim-treesitter/configs.lua +++ b/lua/nvim-treesitter/configs.lua @@ -151,6 +151,19 @@ local function toggle_module(mod, bufnr, lang) end end +-- Toggles the module globally and for all current buffers. +-- @param mod path to module +local function toggle_all(mod) + local config_mod = M.get_module(mod) + if not config_mod then return end + + if config_mod.enable then + disable_all(mod) + else + enable_all(mod) + end +end + -- Recurses through all modules including submodules -- @param accumulator function called for each module -- @param root root configuration table to start at @@ -217,6 +230,13 @@ M.commands = { "-complete=custom,nvim_treesitter#available_modules", }, }, + TSToggleAll = { + run = toggle_all, + args = { + "-nargs=+", + "-complete=custom,nvim_treesitter#available_modules", + }, + }, TSConfigInfo = { run = config_info, args = { -- cgit v1.2.3