feat: add Honey syntax highlighting
This commit is contained in:
@@ -607,6 +607,47 @@ pub fn main() void {
|
||||
assert_eq!(kind_at(&cache, 3, local), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn honey_highlights_declarations_literals_edits_and_markdown_fences() {
|
||||
let source = "Point :: struct { x f64 }\n\
|
||||
add proc(a, b i32) i32 {\n\
|
||||
text := \"hello é\"\n\
|
||||
enabled := true\n\
|
||||
value := 42\n\
|
||||
# note\n\
|
||||
return a + b\n\
|
||||
}";
|
||||
let mut cache = self::cache(source, "main.hon");
|
||||
assert_eq!(cache.language(), Some("Honey"));
|
||||
assert!(!cache.tree.as_ref().unwrap().root_node().has_error());
|
||||
for (row, token, kind) in [
|
||||
(0, "Point", SyntaxKind::Type),
|
||||
(0, "struct", SyntaxKind::Keyword),
|
||||
(0, "f64", SyntaxKind::Type),
|
||||
(1, "add", SyntaxKind::Function),
|
||||
(1, "proc", SyntaxKind::Keyword),
|
||||
(1, "i32", SyntaxKind::Type),
|
||||
(2, "hello é", SyntaxKind::String),
|
||||
(3, "true", SyntaxKind::Keyword),
|
||||
(4, "42", SyntaxKind::Number),
|
||||
(5, "note", SyntaxKind::Comment),
|
||||
(6, "return", SyntaxKind::Keyword),
|
||||
] {
|
||||
assert_token(&cache, source, row, token, kind);
|
||||
}
|
||||
assert_eq!(kind_at(&cache, 6, 7), None);
|
||||
let changed = source.replace("\"hello é\"", "7");
|
||||
cache.update(&lines(&changed), Some(Path::new("main.hon")), 1);
|
||||
assert_token(&cache, &changed, 2, "7", SyntaxKind::Number);
|
||||
assert_fresh(&cache, &changed, "main.hon");
|
||||
for tag in ["honey", "honeylang", "hon"] {
|
||||
let markdown = format!("```{tag}\n{source}\n```");
|
||||
let injected = self::cache(&markdown, "README.md");
|
||||
assert_token(&injected, &markdown, 2, "add", SyntaxKind::Function);
|
||||
assert_token(&injected, &markdown, 3, "hello é", SyntaxKind::String);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn filenames_shebang_save_as_and_tsx_use_actual_grammar_identity() {
|
||||
let source = lines("\u{feff}#!/usr/bin/env python3\nreturn 42");
|
||||
|
||||
Reference in New Issue
Block a user