Add style for rainbow ig, dimming, normal and none

pull/6/head
SoraTenshi 2 years ago
parent 136487fcde
commit 52db599f2b

@ -237,12 +237,12 @@ tabpad = "·" # Tabs will look like "→···" (depending on tab width)
Options for rendering vertical indent guides. Options for rendering vertical indent guides.
| Key | Description | Default | | Key | Description | Default |
| --- | --- | --- | | --- | --- | --- |
| `render` | Whether to render indent guides. | `false` | | `render` | Whether to render indent guides. | `false` |
| `character` | Literal character to use for rendering the indent guide | `│` | | `character` | Literal character to use for rendering the indent guide | `│` |
| `rainbow` | Whether or not the indent guides shall have changing colors. | `false` | | `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` | | `skip-levels` | Number of indent levels to skip | `0` |
Example: Example:
@ -250,6 +250,6 @@ Example:
[editor.indent-guides] [editor.indent-guides]
render = true render = true
character = "╎" character = "╎"
rainbow = true rainbow = "normal"
skip-levels = 1 skip-levels = 1
``` ```

@ -17,7 +17,7 @@ use helix_core::{
}; };
use helix_view::{ use helix_view::{
document::{Mode, SCRATCH_BUFFER_NAME}, document::{Mode, SCRATCH_BUFFER_NAME},
editor::{CompleteAction, CursorShapeConfig}, editor::{CompleteAction, CursorShapeConfig, RainbowIndentOptions},
graphics::{Color, CursorKind, Modifier, Rect, Style}, graphics::{Color, CursorKind, Modifier, Rect, Style},
input::{KeyEvent, MouseButton, MouseEvent, MouseEventKind}, input::{KeyEvent, MouseButton, MouseEvent, MouseEventKind},
keyboard::{KeyCode, KeyModifiers}, keyboard::{KeyCode, KeyModifiers},
@ -443,9 +443,17 @@ impl EditorView {
// TODO: limit to a max indent level too. It doesn't cause visual artifacts but it would avoid some // TODO: limit to a max indent level too. It doesn't cause visual artifacts but it would avoid some
// extra loops if the code is deeply nested. // extra loops if the code is deeply nested.
let modifier = if config.indent_guides.rainbow == RainbowIndentOptions::Dim {
Modifier::DIM
} else {
Modifier::empty()
};
for i in starting_indent..(indent_level / tab_width as u16) { for i in starting_indent..(indent_level / tab_width as u16) {
let style = if config.indent_guides.rainbow { let style = if config.indent_guides.rainbow != RainbowIndentOptions::None {
indent_guide_style.patch(theme.get_rainbow(i as usize)) indent_guide_style
.patch(theme.get_rainbow(i as usize))
.add_modifier(modifier)
} else { } else {
indent_guide_style indent_guide_style
}; };

@ -551,13 +551,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)] #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(default, rename_all = "kebab-case")] #[serde(default, rename_all = "kebab-case")]
pub struct IndentGuidesConfig { pub struct IndentGuidesConfig {
pub render: bool, pub render: bool,
pub character: char, pub character: char,
// TODO: Make enum to also support background rainbow for indent guides pub rainbow: RainbowIndentOptions,
pub rainbow: bool,
pub skip_levels: u16, pub skip_levels: u16,
} }
@ -567,7 +574,7 @@ impl Default for IndentGuidesConfig {
skip_levels: 0, skip_levels: 0,
render: false, render: false,
character: '', character: '',
rainbow: false, rainbow: RainbowIndentOptions::None,
} }
} }
} }

Loading…
Cancel
Save