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.
| 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` |
| `skip-levels` | Number of indent levels to skip | `0` |
| 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` |
Example:
@ -250,6 +250,6 @@ Example:
[editor.indent-guides]
render = true
character = "╎"
rainbow = true
rainbow = "normal"
skip-levels = 1
```

@ -17,7 +17,7 @@ use helix_core::{
};
use helix_view::{
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},
@ -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
// 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) {
let style = if config.indent_guides.rainbow {
indent_guide_style.patch(theme.get_rainbow(i as usize))
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
};

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

Loading…
Cancel
Save