mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 06:44:46 +00:00
Merge pull request #1710 from rtfeldman/highlight-keywords
Syntax highlighting for keywords in reports
This commit is contained in:
commit
cde9f97415
1 changed files with 8 additions and 3 deletions
|
@ -128,6 +128,7 @@ impl<'b> Report<'b> {
|
||||||
pub struct Palette<'a> {
|
pub struct Palette<'a> {
|
||||||
pub primary: &'a str,
|
pub primary: &'a str,
|
||||||
pub code_block: &'a str,
|
pub code_block: &'a str,
|
||||||
|
pub keyword: &'a str,
|
||||||
pub variable: &'a str,
|
pub variable: &'a str,
|
||||||
pub type_variable: &'a str,
|
pub type_variable: &'a str,
|
||||||
pub structure: &'a str,
|
pub structure: &'a str,
|
||||||
|
@ -146,6 +147,7 @@ pub struct Palette<'a> {
|
||||||
pub const DEFAULT_PALETTE: Palette = Palette {
|
pub const DEFAULT_PALETTE: Palette = Palette {
|
||||||
primary: WHITE_CODE,
|
primary: WHITE_CODE,
|
||||||
code_block: WHITE_CODE,
|
code_block: WHITE_CODE,
|
||||||
|
keyword: GREEN_CODE,
|
||||||
variable: BLUE_CODE,
|
variable: BLUE_CODE,
|
||||||
type_variable: YELLOW_CODE,
|
type_variable: YELLOW_CODE,
|
||||||
structure: GREEN_CODE,
|
structure: GREEN_CODE,
|
||||||
|
@ -810,6 +812,9 @@ where
|
||||||
Symbol => {
|
Symbol => {
|
||||||
self.write_str(self.palette.variable)?;
|
self.write_str(self.palette.variable)?;
|
||||||
}
|
}
|
||||||
|
Keyword => {
|
||||||
|
self.write_str(self.palette.keyword)?;
|
||||||
|
}
|
||||||
GutterBar => {
|
GutterBar => {
|
||||||
self.write_str(self.palette.gutter_bar)?;
|
self.write_str(self.palette.gutter_bar)?;
|
||||||
}
|
}
|
||||||
|
@ -837,7 +842,7 @@ where
|
||||||
ParserSuggestion => {
|
ParserSuggestion => {
|
||||||
self.write_str(self.palette.parser_suggestion)?;
|
self.write_str(self.palette.parser_suggestion)?;
|
||||||
}
|
}
|
||||||
TypeBlock | GlobalTag | PrivateTag | RecordField | Keyword => { /* nothing yet */ }
|
TypeBlock | GlobalTag | PrivateTag | RecordField => { /* nothing yet */ }
|
||||||
}
|
}
|
||||||
self.style_stack.push(*annotation);
|
self.style_stack.push(*annotation);
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -851,11 +856,11 @@ where
|
||||||
Some(annotation) => match annotation {
|
Some(annotation) => match annotation {
|
||||||
Emphasized | Url | TypeVariable | Alias | Symbol | BinOp | Error | GutterBar
|
Emphasized | Url | TypeVariable | Alias | Symbol | BinOp | Error | GutterBar
|
||||||
| Typo | TypoSuggestion | ParserSuggestion | Structure | CodeBlock | PlainText
|
| Typo | TypoSuggestion | ParserSuggestion | Structure | CodeBlock | PlainText
|
||||||
| LineNumber | Tip | Module | Header => {
|
| LineNumber | Tip | Module | Header | Keyword => {
|
||||||
self.write_str(RESET_CODE)?;
|
self.write_str(RESET_CODE)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeBlock | GlobalTag | PrivateTag | RecordField | Keyword => { /* nothing yet */ }
|
TypeBlock | GlobalTag | PrivateTag | RecordField => { /* nothing yet */ }
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue