diff --git a/book/src/configuration.md b/book/src/configuration.md index 9036b5018b87c..a6ac582cccacc 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -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 diff --git a/book/src/themes.md b/book/src/themes.md index 219b0ee3e1d74..da9c2dcf71fde 100644 --- a/book/src/themes.md +++ b/book/src/themes.md @@ -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) | diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 979b95d997ca7..d994918cc8779 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -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); } diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index c4e9ec283f71a..a19597d317bc4 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -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, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] @@ -261,6 +263,7 @@ impl Default for Config { true_color: false, search: SearchConfig::default(), lsp: LspConfig::default(), + color_column: Vec::new(), } } } diff --git a/theme.toml b/theme.toml index d2c1fc32a13c7..e2182f0ca2116 100644 --- a/theme.toml +++ b/theme.toml @@ -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" }