From 9a3f23b0661f7a37a0dab885fe5eb844b615a22b Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Wed, 1 May 2024 15:52:02 -0700 Subject: Add rainbow tree-sitter highlights ref: https://github.com/helix-editor/helix/issues/695 ref: https://github.com/helix-editor/helix/pull/2857 --- helix-view/src/editor.rs | 8 +++- helix-view/src/theme.rs | 113 +++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 115 insertions(+), 6 deletions(-) (limited to 'helix-view') diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 8013043f..4987c073 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -356,6 +356,8 @@ pub struct Config { pub initial_mode: Mode, /// User supplied digraphs for use with the `insert_diagraphs` command pub digraphs: DigraphStore, + /// Whether to render rainbow highlights. Defaults to `true`. + pub rainbow_brackets: bool, } #[derive(Debug, Clone, PartialEq, Deserialize, Serialize, Eq, PartialOrd, Ord)] @@ -936,6 +938,7 @@ impl Default for Config { explorer: ExplorerConfig::default(), initial_mode: Mode::Normal, digraphs: Default::default(), + rainbow_brackets: true, } } } @@ -1276,8 +1279,9 @@ impl Editor { return; } - let scopes = theme.scopes(); - (*self.syn_loader).load().set_scopes(scopes.to_vec()); + self.syn_loader + .load_full() + .set_scopes(theme.scopes().to_vec()); match preview { ThemeAction::Preview => { diff --git a/helix-view/src/theme.rs b/helix-view/src/theme.rs index 4acc5664..16da247f 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