feat: add Typst syntax and Tinymist defaults

This commit is contained in:
2026-10-22 09:30:22 +02:00
parent ea7c240eb6
commit 03931496bf
14 changed files with 104 additions and 4 deletions
+4 -1
View File
@@ -1280,6 +1280,7 @@ fn lsp_configuration_is_disabled_unless_explicitly_enabled() {
r#"Vamp.configure do |config|
config.lsp["rust"] = false
config.lsp["python"] = false
config.lsp["typst"] = false
config.lsp["not-a-preset"] = false
end"#,
] {
@@ -1299,13 +1300,15 @@ fn lsp_presets_custom_languages_and_overrides_reach_native_configuration() {
config.lsp["rust"] = true
config.lsp["python"] = true
config.lsp["ruby"] = true
config.lsp["typst"] = true
end"#,
);
let config = load_config(&path).unwrap();
assert_eq!(config.lsp.len(), 4);
assert_eq!(config.lsp.len(), 5);
for (language, command, extension) in [
("rust", &["rust-analyzer"][..], "rs"),
("ruby", &["solargraph", "stdio"][..], "rb"),
("typst", &["tinymist", "lsp"][..], "typ"),
] {
let server = config
.lsp
+34
View File
@@ -648,6 +648,40 @@ fn honey_highlights_declarations_literals_edits_and_markdown_fences() {
}
}
#[test]
fn typst_highlights_markup_code_edits_and_fenced_languages() {
let source = "= Heading\n#let message = \"hello é\"\n#let count = 42\n\
#text(message) // note\n*strong* and _emphasis_\n\
```rust\nfn main() { let n = 7; }\n```";
let mut cache = self::cache(source, "main.typ");
assert_eq!(cache.language(), Some("Typst"));
assert!(!cache.tree.as_ref().unwrap().root_node().has_error());
for (row, token, kind) in [
(0, "Heading", SyntaxKind::Markup),
(1, "let", SyntaxKind::Keyword),
(1, "hello é", SyntaxKind::String),
(2, "42", SyntaxKind::Number),
(3, "text", SyntaxKind::Function),
(3, "// note", SyntaxKind::Comment),
(4, "strong", SyntaxKind::Markup),
(4, "emphasis", SyntaxKind::Markup),
(6, "fn", SyntaxKind::Keyword),
(6, "7", SyntaxKind::Number),
] {
assert_token(&cache, source, row, token, kind);
}
let edited = source.replace("\"hello é\"", "false");
cache.update(&lines(&edited), Some(Path::new("main.typ")), 1);
assert_token(&cache, &edited, 1, "false", SyntaxKind::Keyword);
assert_fresh(&cache, &edited, "main.typ");
for tag in ["typst", "typ"] {
let markdown = format!("```{tag}\n#let count = 42\n```");
let injected = self::cache(&markdown, "README.md");
assert_token(&injected, &markdown, 1, "let", SyntaxKind::Keyword);
assert_token(&injected, &markdown, 1, "42", SyntaxKind::Number);
}
}
#[test]
fn filenames_shebang_save_as_and_tsx_use_actual_grammar_identity() {
let source = lines("\u{feff}#!/usr/bin/env python3\nreturn 42");
+2
View File
@@ -22,6 +22,8 @@ fn selected_files_and_auxiliary_grammars_are_registered() {
("main.C", "C++"),
("main.go", "Go"),
("main.zig", "Zig"),
("main.typ", "Typst"),
("main.TYP", "Typst"),
] {
assert_eq!(
detect(Some(Path::new(filename)), None).map(|spec| spec.name),