From a2760bfbd1e3081f30d11ce611d86f3558699101 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Mon, 11 Jul 2022 19:10:57 -0500 Subject: [PATCH 01/13] 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 | 113 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 120 insertions(+), 4 deletions(-) diff --git a/book/src/themes.md b/book/src/themes.md index f040dfb192f2..786ec5aa66fd 100644 --- a/book/src/themes.md +++ b/book/src/themes.md @@ -137,6 +137,17 @@ inherits = "boo_berry" berry = "#2A2A4D" ``` +### 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 4acc56648aa0..16da247f6db6 100644 --- a/helix-view/src/theme.rs +++ b/helix-view/src/theme.rs @@ -216,17 +216,19 @@ pub struct Theme { // tree-sitter highlight styles are stored in a Vec to optimize lookups scopes: Vec, highlights: Vec