A post-modern development environment.
0

Configure Feed

Select the types of activity you want to include in your feed.

Add rainbow indentation guides

author
s0LA1337
committer
Isaac Corbrey
date (Jul 3, 2026, 3:06 PM -0400) commit 8ebd9f61 parent 2868367c change-id noovuupr
+44 -15
+7 -5
book/src/editor.md
··· 364 364 365 365 Options for rendering vertical indent guides. 366 366 367 - | Key | Description | Default | 368 - | --- | --- | --- | 369 - | `render` | Whether to render indent guides | `false` | 370 - | `character` | Literal character to use for rendering the indent guide | `"│"` | 371 - | `skip-levels` | Number of indent levels to skip | `0` | 367 + | Key | Description | Default | 368 + | --- | --- | --- | 369 + | `render` | Whether to render indent guides | `false` | 370 + | `character` | Literal character to use for rendering the indent guide | `"│"` | 371 + | `skip-levels` | Number of indent levels to skip | `0` | 372 + | `rainbow-indent` | Enum to set rainbow indentations. `normal`, `dim`, `none` | `none` | 372 373 373 374 Example: 374 375 ··· 377 378 render = true 378 379 character = "╎" # Some characters that work well: "▏", "┆", "┊", "⸽" 379 380 skip-levels = 1 381 + rainbow-indent = "normal" 380 382 ``` 381 383 382 384 ### `[editor.gutters]` Section
+1 -1
book/src/themes.md
··· 149 149 150 150 ### Rainbow 151 151 152 - The `rainbow` key is used for rainbow highlight for matching brackets. 152 + The `rainbow` key is used for rainbow highlight for matching brackets and indentation. 153 153 The key is a list of styles. 154 154 155 155 ```toml
+22 -9
helix-term/src/ui/document.rs
··· 7 7 use helix_core::text_annotations::TextAnnotations; 8 8 use helix_core::{visual_offset_from_block, Position, RopeSlice}; 9 9 use helix_stdx::rope::RopeSliceExt; 10 - use helix_view::editor::{WhitespaceConfig, WhitespaceRenderValue}; 10 + use helix_view::editor::{RainbowIndent, WhitespaceConfig, WhitespaceRenderValue}; 11 11 use helix_view::graphics::Rect; 12 - use helix_view::theme::Style; 12 + use helix_view::theme::{Modifier, Style}; 13 13 use helix_view::view::ViewPosition; 14 14 use helix_view::{Document, Theme}; 15 15 use tui::buffer::Buffer as Surface; ··· 179 179 pub whitespace_style: Style, 180 180 pub indent_guide_char: String, 181 181 pub indent_guide_style: Style, 182 + pub indent_guide_rainbow: RainbowIndent, 183 + pub theme: &'a Theme, 182 184 pub newline: String, 183 185 pub nbsp: String, 184 186 pub nnbsp: String, ··· 201 203 pub fn new( 202 204 surface: &'a mut Surface, 203 205 doc: &Document, 204 - theme: &Theme, 206 + theme: &'a Theme, 205 207 offset: Position, 206 208 viewport: Rect, 207 209 ) -> TextRenderer<'a> { ··· 243 245 }; 244 246 245 247 let text_style = theme.get("ui.text"); 248 + let basic_style = text_style.patch( 249 + theme 250 + .try_get("ui.virtual.indent-guide") 251 + .unwrap_or_else(|| theme.get("ui.virtual.whitespace")), 252 + ); 246 253 247 254 let indent_width = doc.indent_style.indent_width(tab_width) as u16; 248 255 249 256 TextRenderer { 250 257 surface, 251 258 indent_guide_char: editor_config.indent_guides.character.into(), 259 + indent_guide_rainbow: editor_config.indent_guides.rainbow_indent.clone(), 260 + theme, 252 261 newline, 253 262 nbsp, 254 263 nnbsp, ··· 260 269 starting_indent: offset.col / indent_width as usize 261 270 + !offset.col.is_multiple_of(indent_width as usize) as usize 262 271 + editor_config.indent_guides.skip_levels as usize, 263 - indent_guide_style: text_style.patch( 264 - theme 265 - .try_get("ui.virtual.indent-guide") 266 - .unwrap_or_else(|| theme.get("ui.virtual.whitespace")), 267 - ), 272 + indent_guide_style: basic_style, 268 273 text_style, 269 274 draw_indent_guides: editor_config.indent_guides.render, 270 275 viewport, ··· 417 422 as u16; 418 423 let y = self.viewport.y + row; 419 424 debug_assert!(self.surface.in_bounds(x, y)); 425 + let style = match self.indent_guide_rainbow { 426 + RainbowIndent::None => self.indent_guide_style, 427 + RainbowIndent::Dim => self 428 + .indent_guide_style 429 + .patch(self.theme.get_rainbow(i)) 430 + .add_modifier(Modifier::DIM), 431 + RainbowIndent::Normal => self.indent_guide_style.patch(self.theme.get_rainbow(i)), 432 + }; 420 433 self.surface 421 - .set_string(x, y, &self.indent_guide_char, self.indent_guide_style); 434 + .set_string(x, y, &self.indent_guide_char, style) 422 435 } 423 436 } 424 437
+10
helix-view/src/editor.rs
··· 1090 1090 } 1091 1091 1092 1092 #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] 1093 + #[serde(rename_all = "kebab-case")] 1094 + pub enum RainbowIndent { 1095 + None, 1096 + Dim, 1097 + Normal, 1098 + } 1099 + 1100 + #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] 1093 1101 #[serde(default, rename_all = "kebab-case")] 1094 1102 pub struct IndentGuidesConfig { 1095 1103 pub render: bool, 1096 1104 pub character: char, 1097 1105 pub skip_levels: u8, 1106 + pub rainbow_indent: RainbowIndent, 1098 1107 } 1099 1108 1100 1109 impl Default for IndentGuidesConfig { ··· 1103 1112 skip_levels: 0, 1104 1113 render: false, 1105 1114 character: '│', 1115 + rainbow_indent: RainbowIndent::None, 1106 1116 } 1107 1117 } 1108 1118 }
+4
helix-view/src/theme.rs
··· 476 476 self.rainbow_length 477 477 } 478 478 479 + pub fn get_rainbow(&self, index: usize) -> Style { 480 + self.highlights[index % self.rainbow_length] 481 + } 482 + 479 483 fn from_toml(value: Value) -> (Self, Vec<String>) { 480 484 if let Value::Table(table) = value { 481 485 Theme::from_keys(table)