Skip to content

Commit

Permalink
Add option to skip the first indent guide (#3819)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
4 people authored Oct 3, 2022
1 parent dbec057 commit 6764744
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
10 changes: 6 additions & 4 deletions book/src/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,17 @@ 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 | `` |
| 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` |

Example:

```toml
[editor.indent-guides]
render = true
character = ""
skip-levels = 1
```
3 changes: 2 additions & 1 deletion helix-term/src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,8 @@ impl EditorView {
return;
}

let starting_indent = (offset.col / tab_width) as u16;
let starting_indent =
(offset.col / tab_width) as u16 + config.indent_guides.skip_levels;
// 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.

Expand Down
4 changes: 3 additions & 1 deletion helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,15 +552,17 @@ impl Default for WhitespaceCharacters {
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(default)]
#[serde(default, rename_all = "kebab-case")]
pub struct IndentGuidesConfig {
pub render: bool,
pub character: char,
pub skip_levels: u16,
}

impl Default for IndentGuidesConfig {
fn default() -> Self {
Self {
skip_levels: 0,
render: false,
character: '│',
}
Expand Down

0 comments on commit 6764744

Please sign in to comment.