Skip to content

Commit 6764744

Browse files
robinvdRobinA-Walrusthe-mikedavis
authored
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 <[email protected]> * Update helix-term/src/ui/editor.rs Co-authored-by: Michael Davis <[email protected]> Co-authored-by: Robin <[email protected]> Co-authored-by: A-Walrus <[email protected]> Co-authored-by: Michael Davis <[email protected]>
1 parent dbec057 commit 6764744

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

book/src/configuration.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,17 @@ tabpad = "·" # Tabs will look like "→···" (depending on tab width)
233233

234234
Options 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

241242
Example:
242243

243244
```toml
244245
[editor.indent-guides]
245246
render = true
246247
character = ""
248+
skip-levels = 1
247249
```

helix-term/src/ui/editor.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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")]
556556
pub struct IndentGuidesConfig {
557557
pub render: bool,
558558
pub character: char,
559+
pub skip_levels: u16,
559560
}
560561

561562
impl Default for IndentGuidesConfig {
562563
fn default() -> Self {
563564
Self {
565+
skip_levels: 0,
564566
render: false,
565567
character: '│',
566568
}

0 commit comments

Comments
 (0)