From f76e1cfd91a4bbf88fc32fcca750dfcceb7a615d Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Wed, 6 Dec 2023 21:38:30 +0200 Subject: [PATCH] Pass proper theme colors for inlays and suggestions --- crates/editor2/src/display_map.rs | 6 +++--- crates/editor2/src/editor.rs | 27 +++++++++++++++++++++++++++ crates/language2/src/highlight_map.rs | 2 -- crates/theme2/src/one_themes.rs | 2 -- crates/theme2/src/styles/syntax.rs | 12 ------------ 5 files changed, 30 insertions(+), 19 deletions(-) diff --git a/crates/editor2/src/display_map.rs b/crates/editor2/src/display_map.rs index 1aee04dd0ae02b8d4ea98025be177a82e3801ef7..9cc16933711c221a3605bbeca01ba13931048a7b 100644 --- a/crates/editor2/src/display_map.rs +++ b/crates/editor2/src/display_map.rs @@ -24,7 +24,7 @@ use lsp::DiagnosticSeverity; use std::{any::TypeId, borrow::Cow, fmt::Debug, num::NonZeroU32, ops::Range, sync::Arc}; use sum_tree::{Bias, TreeMap}; use tab_map::TabMap; -use theme::{SyntaxTheme, Theme}; +use theme::{StatusColors, SyntaxTheme, Theme}; use wrap_map::WrapMap; pub use block_map::{ @@ -513,8 +513,8 @@ impl DisplaySnapshot { self.chunks( display_rows, language_aware, - Some(editor_style.syntax.inlay_style), - Some(editor_style.syntax.suggestion_style), + Some(editor_style.hints_style), + Some(editor_style.suggestions_style), ) .map(|chunk| { let mut highlight_style = chunk diff --git a/crates/editor2/src/editor.rs b/crates/editor2/src/editor.rs index 3994990f6414a6a59582e7bba712623bd88255d4..3dbdbf5e3c400ce4b99c441d60ed44770a0f9164 100644 --- a/crates/editor2/src/editor.rs +++ b/crates/editor2/src/editor.rs @@ -499,6 +499,8 @@ pub struct EditorStyle { pub scrollbar_width: Pixels, pub syntax: Arc, pub diagnostic_style: DiagnosticStyle, + pub hints_style: HighlightStyle, + pub suggestions_style: HighlightStyle, } type CompletionId = usize; @@ -7640,6 +7642,18 @@ impl Editor { .editor_style .diagnostic_style .clone(), + // todo!("what about the rest of the highlight style parts for inlays and suggestions?") + hints_style: HighlightStyle { + color: Some(cx.theme().status().hint), + font_weight: Some(FontWeight::BOLD), + fade_out: Some(0.6), + ..HighlightStyle::default() + }, + suggestions_style: HighlightStyle { + color: Some(cx.theme().status().predictive), + fade_out: Some(0.6), + ..HighlightStyle::default() + }, }, )) .into_any_element() @@ -9302,6 +9316,19 @@ impl Render for Editor { scrollbar_width: px(12.), syntax: cx.theme().syntax().clone(), diagnostic_style: cx.theme().diagnostic_style(), + // TODO kb find `HighlightStyle` usages + // todo!("what about the rest of the highlight style parts?") + hints_style: HighlightStyle { + color: Some(cx.theme().status().hint), + font_weight: Some(FontWeight::BOLD), + fade_out: Some(0.6), + ..HighlightStyle::default() + }, + suggestions_style: HighlightStyle { + color: Some(cx.theme().status().predictive), + fade_out: Some(0.6), + ..HighlightStyle::default() + }, }, ) } diff --git a/crates/language2/src/highlight_map.rs b/crates/language2/src/highlight_map.rs index 8e7a35233cf2e702536241099619cb0bff53459e..270ac259c9d78eff8d36a2ee8c8038f117d33260 100644 --- a/crates/language2/src/highlight_map.rs +++ b/crates/language2/src/highlight_map.rs @@ -95,8 +95,6 @@ mod tests { .iter() .map(|(name, color)| (name.to_string(), (*color).into())) .collect(), - inlay_style: HighlightStyle::default(), - suggestion_style: HighlightStyle::default(), }; let capture_names = &[ diff --git a/crates/theme2/src/one_themes.rs b/crates/theme2/src/one_themes.rs index e1fb5f1bed21422f64eb210899b3850f7bb1c6d2..fbcabc0ff3897a9b5156f19af8c2cf08361f33f3 100644 --- a/crates/theme2/src/one_themes.rs +++ b/crates/theme2/src/one_themes.rs @@ -191,8 +191,6 @@ pub(crate) fn one_dark() -> Theme { ("variable.special".into(), red.into()), ("variant".into(), HighlightStyle::default()), ], - inlay_style: HighlightStyle::default(), - suggestion_style: HighlightStyle::default(), }), }, } diff --git a/crates/theme2/src/styles/syntax.rs b/crates/theme2/src/styles/syntax.rs index cc73caa6dfca3c920cf79af89eb7d1993d670688..0f35bf60a73aa634bf0953e19f4beea1354131c3 100644 --- a/crates/theme2/src/styles/syntax.rs +++ b/crates/theme2/src/styles/syntax.rs @@ -8,12 +8,6 @@ use crate::{ #[derive(Clone, Default)] pub struct SyntaxTheme { pub highlights: Vec<(String, HighlightStyle)>, - // todo!("Remove this in favor of StatusColor.hint") - // If this should be overridable we should move it to ThemeColors - pub inlay_style: HighlightStyle, - // todo!("Remove this in favor of StatusColor.prediction") - // If this should be overridable we should move it to ThemeColors - pub suggestion_style: HighlightStyle, } impl SyntaxTheme { @@ -72,8 +66,6 @@ impl SyntaxTheme { ("variable.special".into(), red().light().step_9().into()), ("variant".into(), red().light().step_9().into()), ], - inlay_style: tomato().light().step_1().into(), // todo!("nate: use a proper style") - suggestion_style: orange().light().step_1().into(), // todo!("nate: use proper style") } } @@ -132,8 +124,6 @@ impl SyntaxTheme { ("variable.special".into(), red().dark().step_11().into()), ("variant".into(), red().dark().step_11().into()), ], - inlay_style: neutral().dark().step_11().into(), // todo!("nate: use a proper style") - suggestion_style: orange().dark().step_11().into(), // todo!("nate: use a proper style") } } @@ -152,8 +142,6 @@ impl SyntaxTheme { ) }) .collect(), - inlay_style: HighlightStyle::default(), - suggestion_style: HighlightStyle::default(), } }