From b02d6d98ce92824198f44caa687d4f40b9cb76a1 Mon Sep 17 00:00:00 2001 From: s0LA1337 Date: Thu, 6 Oct 2022 18:00:33 +0000 Subject: [PATCH 1/4] Add get_rainbow method, added a todo for rainbow --- helix-term/src/ui/editor.rs | 3 +-- helix-view/src/editor.rs | 2 ++ helix-view/src/theme.rs | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 1431bef2..02b240a9 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -442,8 +442,7 @@ impl EditorView { 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))) + indent_guide_style.patch(theme.get_rainbow(i as usize)) } else { indent_guide_style }; diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 5acbc5b7..2f4909f6 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -533,6 +533,8 @@ impl Default for WhitespaceCharacters { pub struct IndentGuidesConfig { pub render: bool, pub character: char, + + // TODO: Make enum to also support background rainbow for indent guides pub rainbow: bool, } diff --git a/helix-view/src/theme.rs b/helix-view/src/theme.rs index 8472ec64..87ad1e69 100644 --- a/helix-view/src/theme.rs +++ b/helix-view/src/theme.rs @@ -213,6 +213,10 @@ impl Theme { self.rainbow_length } + pub fn get_rainbow(&self, index: usize) -> Style { + self.highlights[index % self.rainbow_length] + } + pub fn default_rainbow() -> Vec