on master help sign in
feat(tree-sitter): :sparkles: add go template support (#3091)
2ede98cDaniel Longeuay
book/src/generated/lang-support.md+1
@@ -34,6 +34,7 @@
34| glsl | ✓ | ✓ | ✓ | |
34| glsl | ✓ | ✓ | ✓ | |
35| go | ✓ | ✓ | ✓ | `gopls` |
35| go | ✓ | ✓ | ✓ | `gopls` |
36| gomod | ✓ | | | `gopls` |
36| gomod | ✓ | | | `gopls` |
37+| gotmpl | ✓ | | | `gopls` |
37| gowork | ✓ | | | `gopls` |
38| gowork | ✓ | | | `gopls` |
38| graphql | ✓ | | | |
39| graphql | ✓ | | | |
39| hare | ✓ | | ✓ | |
40| hare | ✓ | | ✓ | |
languages.toml+14
@@ -285,6 +285,20 @@ indent = { tab-width = 4, unit = "\t" }
285name = "gomod"
285name = "gomod"
286source = { git = "https://github.com/camdencheek/tree-sitter-go-mod", rev = "e8f51f8e4363a3d9a427e8f63f4c1bbc5ef5d8d0" }
286source = { git = "https://github.com/camdencheek/tree-sitter-go-mod", rev = "e8f51f8e4363a3d9a427e8f63f4c1bbc5ef5d8d0" }
287
287
288+[[language]]
289+name = "gotmpl"
290+scope = "source.gotmpl"
291+injection-regex = "gotmpl"
292+file-types = ["gotmpl"]
293+roots = []
294+comment-token = "//"
295+language-server = { command = "gopls" }
296+indent = { tab-width = 2, unit = " " }
297+
298+[[grammar]]
299+name = "gotmpl"
300+source = { git = "https://github.com/dannylongeuay/tree-sitter-go-template", rev = "395a33e08e69f4155156f0b90138a6c86764c979" }
301+
288[[language]]
302[[language]]
289name = "gowork"
303name = "gowork"
290scope = "source.gowork"
304scope = "source.gowork"
runtime/queries/gotmpl/highlights.scmnew file+76
@@ -0,0 +1,76 @@
1+; Identifiers
2+
3+[
4+ (field)
5+ (field_identifier)
6+] @variable.other.member
7+
8+(variable) @variable
9+
10+; Function calls
11+
12+(function_call
13+ function: (identifier) @function)
14+
15+(method_call
16+ method: (selector_expression
17+ field: (field_identifier) @function))
18+
19+; Operators
20+
21+"|" @operator
22+":=" @operator
23+
24+; Builtin functions
25+
26+((identifier) @function.builtin
27+ (#match? @function.builtin "^(and|call|html|index|slice|js|len|not|or|print|printf|println|urlquery|eq|ne|lt|ge|gt|ge)$"))
28+
29+; Delimiters
30+
31+"." @punctuation.delimiter
32+"," @punctuation.delimiter
33+
34+"{{" @punctuation.bracket
35+"}}" @punctuation.bracket
36+"{{-" @punctuation.bracket
37+"-}}" @punctuation.bracket
38+")" @punctuation.bracket
39+"(" @punctuation.bracket
40+
41+; Keywords
42+
43+"else" @keyword
44+"if" @keyword
45+"range" @keyword
46+"with" @keyword
47+"end" @keyword
48+"template" @keyword
49+"define" @keyword
50+"block" @keyword
51+
52+; Literals
53+
54+[
55+ (interpreted_string_literal)
56+ (raw_string_literal)
57+ (rune_literal)
58+] @string
59+
60+(escape_sequence) @string.special
61+
62+[
63+ (int_literal)
64+ (float_literal)
65+ (imaginary_literal)
66+] @constant.numeric.integer
67+
68+[
69+ (true)
70+ (false)
71+] @constant.builtin.boolean
72+
73+(nil) @constant.builtin
74+
75+(comment) @comment
76+(ERROR) @error
runtime/queries/gotmpl/injections.scmnew file+2
@@ -0,0 +1,2 @@
1+((comment) @injection.content
2+ (#set! injection.language "comment"))