Skip to content

Commit

Permalink
feat(indent): added bracker-pair-colorizer plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ammuench committed Apr 20, 2024
1 parent 0c21abb commit 21bbf3f
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions lua/astrocommunity/indent/bracket-pair-colorizer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# bracket-pair-colorizer

Provides rainbow indent guides that tie into their relevant bracket pairs, and a scope guide

**Repository:** <https://github.com/lukas-reineke/indent-blankline.nvim>
**Repository:** <https://gitlab.com/HiPhish/rainbow-delimiters.nvim>

Adds rainbow indent guides to all indents that also align with the bracket for a given indent if available.

Turns the bracket guide into a solid bold line when within the scope of a function/closure.

Adds new mappings to toggle lines & scope highlighting.

```lua
["<leader>uI"] = { ":IBLToggle<cr>", desc = "Toggle Rainbow Indents" },
["<leader>uO"] = { ":IBLToggleScope<cr>", desc = "Toggle Scope Highlights" },
```

Scope higlighting functionality can be disabled by adding this command into your `init.lua` or simliar config:

```lua
vim.cmd(":IBLDisableScope")
```

## Preview

![indent-colorizer-preview](https://github.com/ammuench/astrocommunity-rainbow-higlights/blob/main/lua/astrocommunity/indent/bracket-pair-colorizer/.readme/indent-colorizer-preview.png?raw=true)
62 changes: 62 additions & 0 deletions lua/astrocommunity/indent/bracket-pair-colorizer/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
return {
{
"HiPhish/rainbow-delimiters.nvim",
main = "rainbow_delimiters",
opts = {},
config = function() require("rainbow-delimiters.setup").setup {} end,
},
{
"lukas-reineke/indent-blankline.nvim",
main = "ibl",
opts = {},
config = function()
local highlight = {
"RainbowRed",
"RainbowYellow",
"RainbowBlue",
"RainbowOrange",
"RainbowGreen",
"RainbowViolet",
"RainbowCyan",
}

local highlightIndent = {
"RainbowRedIndent",
"RainbowYellowIndent",
"RainbowBlueIndent",
"RainbowOrangeIndent",
"RainbowGreenIndent",
"RainbowVioletIndent",
"RainbowCyanIndent",
}

local hooks = require "ibl.hooks"
-- create the highlight groups in the highlight setup hook, so they are reset
-- every time the colorscheme changes
hooks.register(hooks.type.HIGHLIGHT_SETUP, function()
vim.api.nvim_set_hl(0, "RainbowRed", { fg = "#E06C75" })
vim.api.nvim_set_hl(0, "RainbowYellow", { fg = "#E5C07B" })
vim.api.nvim_set_hl(0, "RainbowBlue", { fg = "#61AFEF" })
vim.api.nvim_set_hl(0, "RainbowOrange", { fg = "#D19A66" })
vim.api.nvim_set_hl(0, "RainbowGreen", { fg = "#98C379" })
vim.api.nvim_set_hl(0, "RainbowViolet", { fg = "#C678DD" })
vim.api.nvim_set_hl(0, "RainbowCyan", { fg = "#56B6C2" })
vim.api.nvim_set_hl(0, "RainbowRedIndent", { fg = "#6e171e" })
vim.api.nvim_set_hl(0, "RainbowYellowIndent", { fg = "#765517" })
vim.api.nvim_set_hl(0, "RainbowBlueIndent", { fg = "#0c497a" })
vim.api.nvim_set_hl(0, "RainbowOrangeIndent", { fg = "#603d1d" })
vim.api.nvim_set_hl(0, "RainbowGreenIndent", { fg = "#3b5727" })
vim.api.nvim_set_hl(0, "RainbowVioletIndent", { fg = "#5a1b6d" })
vim.api.nvim_set_hl(0, "RainbowCyanIndent", { fg = "#1e4c52" })
end)

vim.g.rainbow_delimiters = { highlight = highlight }
require("ibl").setup {
scope = { highlight = highlight, char = "" },
indent = { highlight = highlightIndent, char = "" },
}

hooks.register(hooks.type.SCOPE_HIGHLIGHT, hooks.builtin.scope_highlight_from_extmark)
end,
},
}

0 comments on commit 21bbf3f

Please sign in to comment.