Skip to content

Commit 3484afa

Browse files
feat: Add Typst support (#272)
1 parent ff0060f commit 3484afa

File tree

5 files changed

+86
-0
lines changed

5 files changed

+86
-0
lines changed

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,3 +508,9 @@
508508
update = none
509509
ignore = dirty
510510
branch = master
511+
[submodule "repos/typst"]
512+
path = repos/typst
513+
url = https://github.com/uben0/tree-sitter-typst
514+
update = none
515+
ignore = dirty
516+
branch = master

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Changelog
22

33
## Unreleased
4+
- Add `Typst` support
45

56
## 0.12.73 - 2023-10-31
67
- Add `Groovy` support

queries/typst/highlights.scm

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
(call
2+
item: (ident) @function)
3+
(call
4+
item: (field field: (ident) @function.method))
5+
(tagged field: (ident) @tag)
6+
(field field: (ident) @tag)
7+
(comment) @comment
8+
9+
; CONTROL
10+
(let "let" @keyword.storage.type)
11+
(branch ["if" "else"] @keyword.control.conditional)
12+
(while "while" @keyword.control.repeat)
13+
(for ["for" "in"] @keyword.control.repeat)
14+
(import "import" @keyword.control.import)
15+
(as "as" @keyword.operator)
16+
(include "include" @keyword.control.import)
17+
(show "show" @keyword.control)
18+
(set "set" @keyword.control)
19+
(return "return" @keyword.control)
20+
(flow ["break" "continue"] @keyword.control)
21+
22+
; OPERATOR
23+
(in ["in" "not"] @keyword.operator)
24+
(and "and" @keyword.operator)
25+
(or "or" @keyword.operator)
26+
(not "not" @keyword.operator)
27+
(sign ["+" "-"] @operator)
28+
(add "+" @operator)
29+
(sub "-" @operator)
30+
(mul "*" @operator)
31+
(div "/" @operator)
32+
(cmp ["==" "<=" ">=" "!=" "<" ">"] @operator)
33+
(fraction "/" @operator)
34+
(fac "!" @operator)
35+
(attach ["^" "_"] @operator)
36+
(wildcard) @operator
37+
38+
; VALUE
39+
(raw_blck "```" @operator) @markup.raw.block
40+
(raw_span "`" @operator) @markup.raw.block
41+
(raw_blck lang: (ident) @tag)
42+
(label) @tag
43+
(ref) @tag
44+
(number) @constant.numeric
45+
(string) @string
46+
(content ["[" "]"] @operator)
47+
(bool) @constant.builtin.boolean
48+
(builtin) @constant.builtin
49+
(none) @constant.builtin
50+
(auto) @constant.builtin
51+
(ident) @variable
52+
(call
53+
item: (builtin) @function.builtin)
54+
55+
; MARKUP
56+
(item "-" @markup.list)
57+
(term ["/" ":"] @markup.list)
58+
(heading ["=" "==" "===" "====" "====="] @markup.heading.marker) @markup.heading
59+
(url) @tag
60+
(emph) @markup.italic
61+
(strong) @markup.bold
62+
(symbol) @constant.character
63+
(shorthand) @constant.builtin
64+
(quote) @markup.quote
65+
(align) @operator
66+
(letter) @constant.character
67+
(linebreak) @constant.builtin
68+
69+
(math "$" @operator)
70+
"#" @operator
71+
"end" @operator
72+
73+
(escape) @constant.character.escape
74+
["(" ")" "{" "}"] @punctuation.bracket
75+
["," ";" ".." ":" "sep"] @punctuation.delimiter
76+
"assign" @punctuation
77+
(field "." @punctuation)

repos/typst

Submodule typst added at 8be2b20

tree-sitter-langs.el

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ See `tree-sitter-langs-repos'."
195195
(tcl-mode . tcl)
196196
(tuareg-mode . ocaml)
197197
(typescript-mode . typescript)
198+
(typst-mode . typst)
198199
(verilog-mode . verilog)
199200
(vhdl-mode . vhdl)
200201
(nxml-mode . xml)

0 commit comments

Comments
 (0)