diff --git a/book/src/configuration.md b/book/src/configuration.md index 78a69baa..41563f4f 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -254,12 +254,40 @@ Sets explorer side width and style. Options for rendering vertical indent guides. +<<<<<<< HEAD | Key | Description | Default | | --- | --- | --- | | `render` | Whether to render indent guides. | `true` | | `character` | Literal character to use for rendering the indent guide | `│` | | `rainbow` | Whether or not the indent guides shall have changing colors. | `false` | | `skip-levels` | Number of indent levels to skip | `0` | +||||||| merged common ancestors +<<<<<<<<< Temporary merge branch 1 +| 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` | +||||||||| 60aa7d36 +| 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 | `│` | +| `skip-levels` | Number of indent levels to skip | `0` | +>>>>>>>>> Temporary merge branch 2 +======= +| 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. It can be `none`, `dim` or `normal`| `none` | +| `skip-levels` | Number of indent levels to skip | `0` | +>>>>>>> colored-indent-guides Example: @@ -267,7 +295,18 @@ Example: [editor.indent-guides] render = true character = "╎" +<<<<<<< HEAD +rainbow = true +||||||| merged common ancestors rainbow = true +||||||||| 60aa7d36 +character = "╎" +========= +character = "╎" # Some characters that work well: "▏", "┆", "┊", "⸽" +======= +rainbow = "normal" +character = "╎" # Some characters that work well: "▏", "┆", "┊", "⸽" +>>>>>>> colored-indent-guides skip-levels = 1 ``` diff --git a/book/src/themes.md b/book/src/themes.md index b3145a8c..fb6e26ee 100644 --- a/book/src/themes.md +++ b/book/src/themes.md @@ -107,6 +107,7 @@ Some styles might not be supported by your terminal emulator. | `double_line` | +<<<<<<< HEAD <<<<<<< HEAD ### Rainbow @@ -121,6 +122,20 @@ Colors from the palette and modifiers may be used. ||||||| 60aa7d36 ======= +||||||| merged common ancestors +======= +### 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. + +>>>>>>> colored-indent-guides ### Inheritance Extend upon other themes by setting the `inherits` property to an existing theme. @@ -136,7 +151,22 @@ inherits = "boo_berry" berry = "#2A2A4D" ``` +<<<<<<< HEAD >>>>>>> seperate_code_action +||||||| merged common ancestors +### 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. + +======= +>>>>>>> colored-indent-guides ### 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 d206cde0..d5d22151 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -19,7 +19,7 @@ use helix_core::{ use helix_view::{ apply_transaction, document::{Mode, SCRATCH_BUFFER_NAME}, - editor::{CompleteAction, CursorShapeConfig}, + editor::{CompleteAction, CursorShapeConfig, RainbowIndentOptions}, graphics::{Color, CursorKind, Modifier, Rect, Style}, input::{KeyEvent, MouseButton, MouseEvent, MouseEventKind}, keyboard::{KeyCode, KeyModifiers}, @@ -471,15 +471,22 @@ impl EditorView { let starting_indent = (offset.col / tab_width) + config.indent_guides.skip_levels as usize; + let modifier = if config.indent_guides.rainbow == RainbowIndentOptions::Dim { + Modifier::DIM + } else { + Modifier::empty() + }; + for i in starting_indent..(indent_level / tab_width) { - 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))) + let style = if config.indent_guides.rainbow != RainbowIndentOptions::None { + indent_guide_style + .patch(theme.get_rainbow(i as usize)) + .add_modifier(modifier) } else { indent_guide_style }; surface.set_string( - viewport.x + ((i * tab_width) - offset.col) as u16, + viewport.x + (i as u16 * tab_width as u16) - offset.col as u16, viewport.y + line, &indent_guide_char, style, diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 613fc559..de999dbe 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -620,12 +620,20 @@ 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 rainbow: bool, + pub rainbow: RainbowIndentOptions, pub skip_levels: u8, } @@ -635,7 +643,7 @@ impl Default for IndentGuidesConfig { render: true, skip_levels: 0, character: '│', - rainbow: false, + rainbow: RainbowIndentOptions::None, } } } diff --git a/helix-view/src/theme.rs b/helix-view/src/theme.rs index 71b96396..5fd6c426 100644 --- a/helix-view/src/theme.rs +++ b/helix-view/src/theme.rs @@ -188,8 +188,8 @@ pub struct Theme { styles: HashMap, // tree-sitter highlight styles are stored in a Vec to optimize lookups scopes: Vec, - highlights: Vec