diff --git a/book/src/configuration.md b/book/src/configuration.md index 5b3f6570..1ebfea78 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -232,10 +232,11 @@ Sets explorer side width and style. Options for rendering vertical indent guides. -| Key | Description | Default | -| --- | --- | --- | -| `render` | Whether to render indent guides. | `false` | -| `character` | Literal character to use for rendering the indent guide | `│` | +| Key | Description | Default | +| --- | --- | --- | +| `render` | Whether to render indent guides. | `false` | +| `character` | Literal character to use for rendering the indent guide | `│` | +| `rainbow` | Whether or not the indent guides shall have changing colors. | `false` | Example: @@ -243,6 +244,7 @@ Example: [editor.indent-guides] render = true character = "╎" +rainbow = true ``` ### `[editor.explorer]` Section diff --git a/book/src/themes.md b/book/src/themes.md index 9908456f..ea516959 100644 --- a/book/src/themes.md +++ b/book/src/themes.md @@ -89,6 +89,17 @@ Less common modifiers might not be supported by your terminal emulator. | `hidden` | | `crossed_out` | +### Rainbow + +The `rainbow` key is used for rainbow highlight for matching brackets. +The key is a list of styles. + +```toml +rainbow = ["#ff0000", "#ffa500", "#fff000", { fg = "#00ff00", modifiers = ["bold"] }] +``` + +Colors from the palette and modifiers may be used. + ### Scopes The following is a list of scopes available to use for styling. diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index b94e01ad..984378a2 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -443,11 +443,18 @@ impl EditorView { // extra loops if the code is deeply nested. for i in starting_indent..(indent_level / tab_width as u16) { + let style = if config.indent_guides.rainbow { + let color_index = i as usize % theme.rainbow_length(); + indent_guide_style.patch(theme.get(&format!("rainbow.{}", color_index))) + } else { + indent_guide_style + }; + surface.set_string( viewport.x + (i * tab_width as u16) - offset.col as u16, viewport.y + line, &indent_guide_char, - indent_guide_style, + style, ); } }; diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index ec291520..bca15f55 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -595,6 +595,7 @@ impl Default for WhitespaceCharacters { pub struct IndentGuidesConfig { pub render: bool, pub character: char, + pub rainbow: bool, } impl Default for IndentGuidesConfig { @@ -602,6 +603,7 @@ impl Default for IndentGuidesConfig { Self { render: true, character: '│', + rainbow: false, } } } diff --git a/helix-view/src/theme.rs b/helix-view/src/theme.rs index fa5fa702..8472ec64 100644 --- a/helix-view/src/theme.rs +++ b/helix-view/src/theme.rs @@ -103,6 +103,7 @@ pub struct Theme { // tree-sitter highlight styles are stored in a Vec to optimize lookups scopes: Vec, highlights: Vec