diff options
| author | echasnovski <evgeni.chasnovski@gmail.com> | 2021-01-31 13:09:25 +0200 |
|---|---|---|
| committer | Stephan Seitz <stephan.lauf@yahoo.de> | 2021-02-01 19:37:39 +0100 |
| commit | fdfbb5c1bf7ad863eb662fdf2e7fb39ed8b1e707 (patch) | |
| tree | 121068fa0f3402912287ea4428e724e7b26f86cd | |
| parent | Implement `TSBufToggle`. (diff) | |
| download | nvim-treesitter-fdfbb5c1bf7ad863eb662fdf2e7fb39ed8b1e707.tar nvim-treesitter-fdfbb5c1bf7ad863eb662fdf2e7fb39ed8b1e707.tar.gz nvim-treesitter-fdfbb5c1bf7ad863eb662fdf2e7fb39ed8b1e707.tar.bz2 nvim-treesitter-fdfbb5c1bf7ad863eb662fdf2e7fb39ed8b1e707.tar.lz nvim-treesitter-fdfbb5c1bf7ad863eb662fdf2e7fb39ed8b1e707.tar.xz nvim-treesitter-fdfbb5c1bf7ad863eb662fdf2e7fb39ed8b1e707.tar.zst nvim-treesitter-fdfbb5c1bf7ad863eb662fdf2e7fb39ed8b1e707.zip | |
Implement `TSToggleAll`.
| -rw-r--r-- | doc/nvim-treesitter.txt | 9 | ||||
| -rw-r--r-- | lua/nvim-treesitter/configs.lua | 20 |
2 files changed, 29 insertions, 0 deletions
diff --git a/doc/nvim-treesitter.txt b/doc/nvim-treesitter.txt index d253194c7..0ee9da127 100644 --- a/doc/nvim-treesitter.txt +++ b/doc/nvim-treesitter.txt @@ -256,6 +256,15 @@ particular language. A list of modules can be found at |:TSModuleInfo| A list of languages can be found at |:TSInstallInfo| + *:TSToggleAll* +:TSToggleAll {module} [{language}]~ + +Toggle (enable if disabled, disable if enabled) {module} for the session. +If {language} is specified, toggle module for the session only for this +particular language. +A list of modules can be found at |:TSModuleInfo| +A list of languages can be found at |:TSInstallInfo| + *:TSModuleInfo* :TSModuleInfo [{module}]~ diff --git a/lua/nvim-treesitter/configs.lua b/lua/nvim-treesitter/configs.lua index 9f7627a00..4b815dd3f 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 = { |
