Skip to content

Commit

Permalink
Add color_column option
Browse files Browse the repository at this point in the history
  • Loading branch information
DeviousStoat committed Apr 10, 2022
1 parent 562874a commit ede0791
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions book/src/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ hidden = false
| `completion-trigger-len` | The min-length of word under cursor to trigger autocompletion | `2` |
| `auto-info` | Whether to display infoboxes | `true` |
| `true-color` | Set to `true` to override automatic detection of terminal truecolor support in the event of a false negative. | `false` |
| `color-column` | List of column positions at which to display the color columns. | `[]` |

### `[editor.lsp]` Section

Expand Down
1 change: 1 addition & 0 deletions book/src/themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ These scopes are used for theming the editor interface.
| `ui.menu.selected` | |
| `ui.selection` | For selections in the editing area |
| `ui.selection.primary` | |
| `ui.colorcolumn` | |
| `warning` | Diagnostics warning (gutter) |
| `error` | Diagnostics error (gutter) |
| `info` | Diagnostics info (gutter) |
Expand Down
18 changes: 18 additions & 0 deletions helix-term/src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,24 @@ impl EditorView {
Self::render_text_highlights(doc, view.offset, inner, surface, theme, highlights);
Self::render_gutter(editor, doc, view, view.area, surface, theme, is_focused);

// Render color columns
editor
.config()
.color_column
.iter()
.filter_map(|column| {
column
.checked_sub(1 + view.offset.col as u16)
.map(|x| {
inner
.with_height((view.last_line(doc) - view.offset.row + 1) as u16)
.clip_left(x)
.with_width(1)
})
.filter(|area| area.left() < inner.right())
})
.for_each(|area| surface.set_style(area, theme.get("ui.colorcolumn")));

if is_focused {
Self::render_focused_view_elements(view, doc, inner, theme, surface);
}
Expand Down
3 changes: 3 additions & 0 deletions helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ pub struct Config {
#[serde(default)]
pub search: SearchConfig,
pub lsp: LspConfig,
/// Column numbers at which to draw the color columns. Default to `[]`, meaning no color column.
pub color_column: Vec<u16>,
}

#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)]
Expand Down Expand Up @@ -261,6 +263,7 @@ impl Default for Config {
true_color: false,
search: SearchConfig::default(),
lsp: LspConfig::default(),
color_column: Vec::new(),
}
}
}
Expand Down
1 change: 1 addition & 0 deletions theme.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ label = "honey"
"ui.cursor.match" = { fg = "#212121", bg = "#6C6999" }
"ui.cursor" = { modifiers = ["reversed"] }
"ui.highlight" = { bg = "bossanova" }
"ui.colorcolumn" = { bg = "gray" }

"ui.menu.selected" = { fg = "revolver", bg = "white" }

Expand Down

0 comments on commit ede0791

Please sign in to comment.