From 368995b51f2b0b8574a87ebe04749cb556b4c538 Mon Sep 17 00:00:00 2001 From: JJ Date: Tue, 31 Oct 2023 18:14:55 -0700 Subject: Add rainbow indentation guides ref: https://github.com/helix-editor/helix/issues/4010 ref: https://github.com/helix-editor/helix/pull/4493 Co-authored-by: SoraTenshi --- helix-view/src/editor.rs | 10 ++++++++++ helix-view/src/theme.rs | 4 ++++ 2 files changed, 14 insertions(+) (limited to 'helix-view') diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index fbfed656..b2615c9f 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -764,12 +764,21 @@ impl Default for WhitespaceCharacters { } } +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "kebab-case")] +pub enum RainbowIndentOptions { + None, + Dim, + Normal, +} + #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] #[serde(default, rename_all = "kebab-case")] pub struct IndentGuidesConfig { pub render: bool, pub character: char, pub skip_levels: u8, + pub rainbow_option: RainbowIndentOptions, } impl Default for IndentGuidesConfig { @@ -778,6 +787,7 @@ impl Default for IndentGuidesConfig { skip_levels: 0, render: false, character: '│', + rainbow_option: RainbowIndentOptions::None, } } } diff --git a/helix-view/src/theme.rs b/helix-view/src/theme.rs index 16da247f..8236d370 100644 --- a/helix-view/src/theme.rs +++ b/helix-view/src/theme.rs @@ -383,6 +383,10 @@ impl Theme { pub fn rainbow_length(&self) -> usize { self.rainbow_length } + + pub fn get_rainbow(&self, index: usize) -> Style { + self.highlights[index % self.rainbow_length] + } } fn default_rainbow() -> Vec