Skip to content

Commit 15f23a3

Browse files
AlexanderBrevigthe-mikedavis
authored andcommitted
Add typst language and lsp (helix-editor#7474)
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
1 parent 64c3a20 commit 15f23a3

4 files changed

Lines changed: 106 additions & 0 deletions

File tree

book/src/generated/lang-support.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@
163163
| tsx |||| `typescript-language-server` |
164164
| twig || | | |
165165
| typescript |||| `typescript-language-server` |
166+
| typst || | | `typst-lsp` |
166167
| ungrammar || | | |
167168
| unison || | | |
168169
| uxntal || | | |

languages.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ wgsl_analyzer = { command = "wgsl_analyzer" }
8888
yaml-language-server = { command = "yaml-language-server", args = ["--stdio"] }
8989
zls = { command = "zls" }
9090
blueprint-compiler = { command = "blueprint-compiler", args = ["lsp"] }
91+
typst-lsp = { command = "typst-lsp" }
9192

9293
[language-server.ansible-language-server]
9394
command = "ansible-language-server"
@@ -2912,6 +2913,27 @@ roots = []
29122913
indent = { tab-width = 2, unit = " " }
29132914
grammar = "html"
29142915

2916+
[[language]]
2917+
name = "typst"
2918+
scope = "source.typst"
2919+
injection-regex = "typst"
2920+
file-types = ["typst", "typ"]
2921+
roots = []
2922+
comment-token = "//"
2923+
language-servers = ["typst-lsp"]
2924+
indent = { tab-width = 2, unit = " " }
2925+
2926+
[language.auto-pairs]
2927+
'(' = ')'
2928+
'{' = '}'
2929+
'[' = ']'
2930+
'$' = '$'
2931+
'"' = '"'
2932+
2933+
[[grammar]]
2934+
name = "typst"
2935+
source = { git = "https://github.com/uben0/tree-sitter-typst", rev = "e35aa22395fdde82bbc4b5700c324ce346dfc9e5" }
2936+
29152937
[[language]]
29162938
name = "nunjucks"
29172939
scope = "text.html.nunjucks"
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)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
(raw_blck
2+
(blob) @injection.shebang @injection.content)
3+
4+
(raw_blck
5+
lang: (ident) @injection.language
6+
(blob) @injection.content)

0 commit comments

Comments
 (0)