1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#[derive(Debug, Copy, Clone, Default, PartialEq, strum::EnumString, strum::Display)]
#[strum(serialize_all = "snake_case")]
pub enum Style {
    Keyword,
    ControlFlow,
    Signal,
    Function,
    Call,
    Symbol,
    Value,
    Number,
    String,
    Brackets,
    Operators,
    Infix,
    Comment,
    #[default]
    None,
}

#[cfg(feature = "repl")]
impl From<Style> for nu_ansi_term::Style {
    fn from(val: Style) -> Self {
        use super::Style::*;
        use nu_ansi_term::{Color, Style};

        match val {
            Symbol => Style::new().fg(Color::White).bold(),
            Call => Style::new().fg(Color::Rgb(122, 162, 247)).italic(),
            Value => Style::new().fg(Color::Rgb(255, 158, 101)),
            Number => Style::new().fg(Color::Rgb(240, 158, 130)),
            String => Style::new().fg(Color::Rgb(158, 206, 106)),
            Comment => Style::new().fg(Color::Rgb(100, 100, 100)),
            Function => Style::new().fg(Color::Rgb(82, 132, 250)).italic().bold(),
            ControlFlow => Style::new().fg(Color::Rgb(187, 154, 246)).italic(),
            Signal => Style::new().fg(Color::Rgb(214, 99, 255)),
            Brackets | Operators | Infix => Style::new().fg(Color::Rgb(170, 170, 190)),
            _ => Style::new().fg(Color::White),
        }
    }
}