Skip to content

Commit 086c6fc

Browse files
Uzaaftazdanov
andauthored
feat(rainbow-delimiters-nvim): add global toggle (#1771)
Co-authored-by: Anton Ždanov <anton@azdanov.dev>
1 parent ec32213 commit 086c6fc

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

lua/astrocommunity/editing-support/rainbow-delimiters-nvim/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,8 @@ Rainbow delimiters for Neovim with Tree-sitter
55
**Repository:** <https://github.com/HiPhish/rainbow-delimiters.nvim>
66

77
This is a hard fork of the nvim-ts-rainbow2 plugin & is recommended over it.
8+
9+
This plugin adds the following mappings:
10+
11+
- `<Leader>u(` toggles rainbow delimiters for the current buffer
12+
- `<Leader>u)` toggles rainbow delimiters globally

lua/astrocommunity/editing-support/rainbow-delimiters-nvim/init.lua

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
local enabled = true
2+
13
return {
24
{
35
"HiPhish/rainbow-delimiters.nvim",
@@ -22,6 +24,21 @@ return {
2224
end,
2325
desc = "Toggle rainbow delimeters (buffer)",
2426
},
27+
["<Leader>u)"] = {
28+
function()
29+
local rainbow_delimiters = require "rainbow-delimiters"
30+
enabled = not enabled
31+
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
32+
if enabled then
33+
rainbow_delimiters.enable(bufnr)
34+
else
35+
rainbow_delimiters.disable(bufnr)
36+
end
37+
end
38+
require("astrocore").notify(string.format("Global rainbow delimeters %s", enabled and "on" or "off"))
39+
end,
40+
desc = "Toggle rainbow delimeters (global)",
41+
},
2542
},
2643
},
2744
},
@@ -40,7 +57,7 @@ return {
4057
opts = {
4158
condition = function(bufnr)
4259
local buf_utils = require "astrocore.buffer"
43-
return buf_utils.is_valid(bufnr) and not buf_utils.is_large(bufnr)
60+
return enabled and buf_utils.is_valid(bufnr) and not buf_utils.is_large(bufnr)
4461
end,
4562
},
4663
},

0 commit comments

Comments
 (0)