on master help sign in
Add option to skip the first indent guide (#3819)

* Add option to skip the first indent guide * reorder skip_first option * change indent-guides.skip_first to a number * rename skip -> skip_levels * add skip_levels to the book * Update book/src/configuration.md Co-authored-by: A-Walrus <58790821+A-Walrus@users.noreply.github.com> * Update helix-term/src/ui/editor.rs Co-authored-by: Michael Davis <mcarsondavis@gmail.com> Co-authored-by: Robin <robinvandijk@klippa.com> Co-authored-by: A-Walrus <58790821+A-Walrus@users.noreply.github.com> Co-authored-by: Michael Davis <mcarsondavis@gmail.com>

commit6764744ce9912a1f48502bf5ee025283e12fded5 authorRobin <robin@robinjint.nl> dateMon 3 Oct 2022, 17:07 (4 years ago) parentdbec057
3 files changed+11−6
book/src/configuration.md+6−4 helix-term/src/ui/editor.rs+2−1 helix-view/src/editor.rs+3−1
book/src/configuration.md+6−4
@@ -233,10 +233,11 @@ tabpad = "·" # Tabs will look like "→···" (depending on tab width)
233233
234234Options for rendering vertical indent guides.
235235
236−| Key | Description | Default |
237−| --- | --- | --- |
238−| `render` | Whether to render indent guides. | `false` |
239−| `character` | Literal character to use for rendering the indent guide | `│` |
236+| Key | Description | Default |
237+| --- | --- | --- |
238+| `render` | Whether to render indent guides. | `false` |
239+| `character` | Literal character to use for rendering the indent guide | `│` |
240+| `skip-levels` | Number of indent levels to skip | `0` |
240241
241242Example:
242243
@@ -244,4 +245,5 @@ Example:
244245[editor.indent-guides]
245246render = true
246247character = "╎"
248+skip-levels = 1
247249```
helix-term/src/ui/editor.rs+2−1
@@ -436,7 +436,8 @@ impl EditorView {
436436 return;
437437 }
438438
439− let starting_indent = (offset.col / tab_width) as u16;
439+ let starting_indent =
440+ (offset.col / tab_width) as u16 + config.indent_guides.skip_levels;
440441 // TODO: limit to a max indent level too. It doesn't cause visual artifacts but it would avoid some
441442 // extra loops if the code is deeply nested.
442443
helix-view/src/editor.rs+3−1
@@ -552,15 +552,17 @@ impl Default for WhitespaceCharacters {
552552}
553553
554554#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
555−#[serde(default)]
555+#[serde(default, rename_all = "kebab-case")]
556556pub struct IndentGuidesConfig {
557557 pub render: bool,
558558 pub character: char,
559+ pub skip_levels: u16,
559560}
560561
561562impl Default for IndentGuidesConfig {
562563 fn default() -> Self {
563564 Self {
565+ skip_levels: 0,
564566 render: false,
565567 character: '│',
566568 }