From 1daf0c35c78fddc21b0418eb33dac8ea734c90d5 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Mon, 11 Jul 2022 19:10:57 -0500 Subject: [PATCH] Parse rainbow style array in themes This change adds a field to the schema of themes which takes a list of styles. rainbow = ["red", "orange", "yellow", { modifiers = ["reversed"] }] [palette] red = "#ff0000" orange = "#ffa500" yellow = "#fff000" Normal style rules apply for each element in `rainbows`: you can use definitions from the palette and the full fg/bg/modifiers notation. Themes written with `rainbow` keys are not backwards compatible. Parsing errors will be generated for older versions of Helix attempting to use themes with `rainbow` keys. A default rainbow is provided with base16 colors. This change is made with rainbow pair characters (parens, brackets, etc.) in mind but it could also be used for other rainbow cosmetic elements like rainbow indent-guides. --- book/src/themes.md | 11 +++++ helix-view/src/theme.rs | 103 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+) diff --git a/book/src/themes.md b/book/src/themes.md index 9908456f..ea516959 100644 --- a/book/src/themes.md +++ b/book/src/themes.md @@ -89,6 +89,17 @@ Less common modifiers might not be supported by your terminal emulator. | `hidden` | | `crossed_out` | +### Rainbow + +The `rainbow` key is used for rainbow highlight for matching brackets. +The key is a list of styles. + +```toml +rainbow = ["#ff0000", "#ffa500", "#fff000", { fg = "#00ff00", modifiers = ["bold"] }] +``` + +Colors from the palette and modifiers may be used. + ### Scopes The following is a list of scopes available to use for styling. diff --git a/helix-view/src/theme.rs b/helix-view/src/theme.rs index fa5fa702..8472ec64 100644 --- a/helix-view/src/theme.rs +++ b/helix-view/src/theme.rs @@ -103,6 +103,7 @@ pub struct Theme { // tree-sitter highlight styles are stored in a Vec to optimize lookups scopes: Vec, highlights: Vec