ts-wasms 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -0
- package/out/bash/tree-sitter-bash.wasm +0 -0
- package/out/c/tree-sitter-c.wasm +0 -0
- package/out/c-sharp/tree-sitter-c_sharp.wasm +0 -0
- package/out/clojure/highlights.scm +29 -0
- package/out/clojure/tree-sitter-clojure.wasm +0 -0
- package/out/clojurescript/highlights.scm +29 -0
- package/out/clojurescript/tree-sitter-clojure.wasm +0 -0
- package/out/commonlisp/tags.scm +122 -0
- package/out/commonlisp/tree-sitter-commonlisp.wasm +0 -0
- package/out/cpp/tree-sitter-cpp.wasm +0 -0
- package/out/css/tree-sitter-css.wasm +0 -0
- package/out/dart/tree-sitter-dart.wasm +0 -0
- package/out/elisp/tree-sitter-elisp.wasm +0 -0
- package/out/elixir/tree-sitter-elixir.wasm +0 -0
- package/out/elm/highlights.scm +76 -0
- package/out/elm/injections.scm +4 -0
- package/out/elm/locals.scm +15 -0
- package/out/elm/tags.scm +19 -0
- package/out/elm/tree-sitter-elm.wasm +0 -0
- package/out/embedded-template/tree-sitter-embedded_template.wasm +0 -0
- package/out/erlang/highlights.scm +230 -0
- package/out/erlang/tree-sitter-erlang.wasm +0 -0
- package/out/go/tree-sitter-go.wasm +0 -0
- package/out/graphql/tree-sitter-graphql.wasm +0 -0
- package/out/haskell/tree-sitter-haskell.wasm +0 -0
- package/out/html/tree-sitter-html.wasm +0 -0
- package/out/java/tree-sitter-java.wasm +0 -0
- package/out/javascript/tree-sitter-javascript.wasm +0 -0
- package/out/json/tree-sitter-json.wasm +0 -0
- package/out/julia/highlights.scm +375 -0
- package/out/julia/injections.scm +42 -0
- package/out/julia/locals.scm +71 -0
- package/out/julia/tree-sitter-julia.wasm +0 -0
- package/out/kotlin/tree-sitter-kotlin.wasm +0 -0
- package/out/lua/highlights.scm +201 -0
- package/out/lua/injections.scm +12 -0
- package/out/lua/locals.scm +32 -0
- package/out/lua/tags.scm +36 -0
- package/out/lua/tree-sitter-lua.wasm +0 -0
- package/out/markdown-tree-sitter-markdown/highlights.scm +52 -0
- package/out/markdown-tree-sitter-markdown/injections.scm +12 -0
- package/out/markdown-tree-sitter-markdown/tree-sitter-markdown.wasm +0 -0
- package/out/markdown-tree-sitter-markdown-inline/highlights.scm +37 -0
- package/out/markdown-tree-sitter-markdown-inline/injections.scm +2 -0
- package/out/markdown-tree-sitter-markdown-inline/tree-sitter-markdown_inline.wasm +0 -0
- package/out/objc/tree-sitter-objc.wasm +0 -0
- package/out/php/highlights.scm +203 -0
- package/out/php/injections-text.scm +3 -0
- package/out/php/injections.scm +10 -0
- package/out/php/tags.scm +40 -0
- package/out/php/tree-sitter-php.wasm +0 -0
- package/out/php-php_only/highlights.scm +203 -0
- package/out/php-php_only/injections-text.scm +3 -0
- package/out/php-php_only/injections.scm +10 -0
- package/out/php-php_only/tags.scm +40 -0
- package/out/{php_only → php-php_only}/tree-sitter-php_only.wasm +0 -0
- package/out/prisma/highlights.scm +39 -0
- package/out/prisma/tree-sitter-prisma.wasm +0 -0
- package/out/python/tree-sitter-python.wasm +0 -0
- package/out/query/tree-sitter-query.wasm +0 -0
- package/out/r/highlights.scm +112 -0
- package/out/r/locals.scm +18 -0
- package/out/r/tags.scm +21 -0
- package/out/r/tree-sitter-r.wasm +0 -0
- package/out/racket/highlights.scm +108 -0
- package/out/racket/locals.scm +34 -0
- package/out/racket/tags.scm +12 -0
- package/out/racket/tree-sitter-racket.wasm +0 -0
- package/out/regex/tree-sitter-regex.wasm +0 -0
- package/out/ruby/tree-sitter-ruby.wasm +0 -0
- package/out/rust/tree-sitter-rust.wasm +0 -0
- package/out/scala/tree-sitter-scala.wasm +0 -0
- package/out/scheme/highlights.scm +84 -0
- package/out/scheme/tree-sitter-scheme.wasm +0 -0
- package/out/sql/tree-sitter-SQL.wasm +0 -0
- package/out/swift/tree-sitter-swift.wasm +0 -0
- package/out/toml/highlights.scm +53 -0
- package/out/toml/tree-sitter-toml.wasm +0 -0
- package/out/typescript/highlights.scm +35 -0
- package/out/typescript/locals.scm +2 -0
- package/out/typescript/tags.scm +23 -0
- package/out/typescript/tree-sitter-typescript.wasm +0 -0
- package/out/typescript-tsx/highlights.scm +35 -0
- package/out/typescript-tsx/locals.scm +2 -0
- package/out/typescript-tsx/tags.scm +23 -0
- package/out/{tsx → typescript-tsx}/tree-sitter-tsx.wasm +0 -0
- package/out/vimdoc/tree-sitter-vimdoc.wasm +0 -0
- package/out/vue/tree-sitter-vue.wasm +0 -0
- package/out/xml/tree-sitter-xml.wasm +0 -0
- package/out/xml-dtd/tree-sitter-dtd.wasm +0 -0
- package/out/yaml/tree-sitter-yaml.wasm +0 -0
- package/out/zig/folds.scm +23 -0
- package/out/zig/highlights.scm +291 -0
- package/out/zig/indents.scm +22 -0
- package/out/zig/injections.scm +10 -0
- package/out/zig/tree-sitter-zig.wasm +0 -0
- package/package.json +76 -63
- package/README +0 -2
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# ts-wasms
|
|
2
|
+
Prebuilt WASM binaries for tree-sitter's language parsers.
|
|
3
|
+
You can find a list of supported packages [here](https://app.unpkg.com/ts-wasms/files/out)
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
```bash
|
|
7
|
+
pnpm add ts-wasms
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
```ts
|
|
12
|
+
import pythonWasm from "ts-wasms/out/python/tree-sitter-python.wasm"
|
|
13
|
+
import pythonHighlights from "ts-wasms/out/python/highlights.scm"
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Each language directory includes a `tree-sitter-<lang>.wasm` file but may also include:
|
|
17
|
+
- `highlights.scm`
|
|
18
|
+
- `injections.scm`
|
|
19
|
+
- `locals.scm`
|
|
20
|
+
- `tags.scm`
|
|
21
|
+
- `folds.scm`
|
|
22
|
+
- `indents.scm`
|
|
23
|
+
|
|
24
|
+
```txt
|
|
25
|
+
out/python/
|
|
26
|
+
├── tree-sitter-python.wasm
|
|
27
|
+
├── highlights.scm
|
|
28
|
+
└── tags.scm
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Licenses
|
|
32
|
+
Licenses belong to their respective upstream grammar authors, however this repo is MIT licensed.
|
|
33
|
+
(If you have a problem with this licensing, please open an issue.)
|
|
File without changes
|
package/out/c/tree-sitter-c.wasm
CHANGED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
;; Literals
|
|
2
|
+
|
|
3
|
+
(num_lit) @number
|
|
4
|
+
|
|
5
|
+
[
|
|
6
|
+
(char_lit)
|
|
7
|
+
(str_lit)
|
|
8
|
+
] @string
|
|
9
|
+
|
|
10
|
+
[
|
|
11
|
+
(bool_lit)
|
|
12
|
+
(nil_lit)
|
|
13
|
+
] @constant.builtin
|
|
14
|
+
|
|
15
|
+
(kwd_lit) @constant
|
|
16
|
+
|
|
17
|
+
;; Comments
|
|
18
|
+
|
|
19
|
+
(comment) @comment
|
|
20
|
+
|
|
21
|
+
;; Treat quasiquotation as operators for the purpose of highlighting.
|
|
22
|
+
|
|
23
|
+
[
|
|
24
|
+
"'"
|
|
25
|
+
"`"
|
|
26
|
+
"~"
|
|
27
|
+
"@"
|
|
28
|
+
"~@"
|
|
29
|
+
] @operator
|
|
Binary file
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
;; Literals
|
|
2
|
+
|
|
3
|
+
(num_lit) @number
|
|
4
|
+
|
|
5
|
+
[
|
|
6
|
+
(char_lit)
|
|
7
|
+
(str_lit)
|
|
8
|
+
] @string
|
|
9
|
+
|
|
10
|
+
[
|
|
11
|
+
(bool_lit)
|
|
12
|
+
(nil_lit)
|
|
13
|
+
] @constant.builtin
|
|
14
|
+
|
|
15
|
+
(kwd_lit) @constant
|
|
16
|
+
|
|
17
|
+
;; Comments
|
|
18
|
+
|
|
19
|
+
(comment) @comment
|
|
20
|
+
|
|
21
|
+
;; Treat quasiquotation as operators for the purpose of highlighting.
|
|
22
|
+
|
|
23
|
+
[
|
|
24
|
+
"'"
|
|
25
|
+
"`"
|
|
26
|
+
"~"
|
|
27
|
+
"@"
|
|
28
|
+
"~@"
|
|
29
|
+
] @operator
|
|
Binary file
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
2
|
+
;;; Function Definitions ;;;;;;;;;;;;;;;;;;;;;;;
|
|
3
|
+
|
|
4
|
+
(defun_header
|
|
5
|
+
function_name: (sym_lit) @name) @definition.function
|
|
6
|
+
|
|
7
|
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
8
|
+
;;; Function Calls ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
9
|
+
;;;
|
|
10
|
+
;;; Basically, we consider every list literal with symbol as the
|
|
11
|
+
;;; first element to be a call to a function named by that element.
|
|
12
|
+
;;; But we must exclude some cases. Note, tree-sitter @ignore
|
|
13
|
+
;;; cases only work if they are declared before the cases
|
|
14
|
+
;;; we want to include.
|
|
15
|
+
|
|
16
|
+
;; Exclude lambda lists for function definitions
|
|
17
|
+
;; For example:
|
|
18
|
+
;;
|
|
19
|
+
;; (defun my-func (arg1 arg2) ...)
|
|
20
|
+
;;
|
|
21
|
+
;; do not treat (arg1 arg2) as a call of function arg1
|
|
22
|
+
;;
|
|
23
|
+
(defun_header
|
|
24
|
+
lambda_list: (list_lit . [(sym_lit) (package_lit)] @ignore))
|
|
25
|
+
|
|
26
|
+
;; Similar to the above, but for
|
|
27
|
+
;;
|
|
28
|
+
;; (defmethod m ((type1 param1) (type2 param2)) ...)
|
|
29
|
+
;;
|
|
30
|
+
;; where list literals having symbol as their first element
|
|
31
|
+
;; are nested inside the lambda list.
|
|
32
|
+
(defun_header
|
|
33
|
+
lambda_list: (list_lit (list_lit . [(sym_lit) (package_lit)] @ignore)))
|
|
34
|
+
|
|
35
|
+
;;
|
|
36
|
+
;; (let ((var ...) (var2 ...)) ...)
|
|
37
|
+
;;
|
|
38
|
+
;; - exclude var, var2
|
|
39
|
+
;; - the same for let*, flet, labels, macrolet, symbol-macrolet
|
|
40
|
+
(list_lit . [(sym_lit) (package_lit)] @name
|
|
41
|
+
. (list_lit (list_lit . [(sym_lit) (package_lit)] @ignore))
|
|
42
|
+
(#match? @name
|
|
43
|
+
"(?i)^(cl:)?(let|let\\*|flet|labels|macrolet|symbol-macrolet)$")
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
;; TODO:
|
|
47
|
+
;; - exclude also:
|
|
48
|
+
;; - (defclass name (parent parent2)
|
|
49
|
+
;; ((slot1 ...)
|
|
50
|
+
;; (slot2 ...))
|
|
51
|
+
;; exclude the parent, slot1, slot2
|
|
52
|
+
;; - (flet ((func-1 (param1 param2))) ...)
|
|
53
|
+
;; - we already exclude func-1, but param1 is still recognized
|
|
54
|
+
;; as a function call - exclude it too
|
|
55
|
+
;; - the same for labels
|
|
56
|
+
;; - the same macrolet
|
|
57
|
+
;; - what else?
|
|
58
|
+
;; (that's a non-goal to completely support all macros
|
|
59
|
+
;; and special operators, but every one we support
|
|
60
|
+
;; makes the solution a little bit better)
|
|
61
|
+
;; - (flet ((func-1 (param1 param2))) ...)
|
|
62
|
+
;; - instead of simply excluding it, as we do today,
|
|
63
|
+
;; tag func-1 as @local.definition.function (I suppose)
|
|
64
|
+
;; - the same for labels, macrolet
|
|
65
|
+
;; - @local.scope for let, let*, flet, labels, macrolet
|
|
66
|
+
;; - I guess the whole span of the scope text,
|
|
67
|
+
;; till the closing paren, should be tagged as @local.scope;
|
|
68
|
+
;; Hopefully, combined with @local.definition.function
|
|
69
|
+
;; withing the scope, the usual @reference.call within
|
|
70
|
+
;; that scope will refer to the local definition,
|
|
71
|
+
;; and there will be no need to use @local.reference.call
|
|
72
|
+
;; (which is more difficult to implement).
|
|
73
|
+
;; - When implementing, remeber the scope rules differences
|
|
74
|
+
;; of let vs let*, flet vs labels.
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
;; Inlclude all other cases - list literal with symbol as the
|
|
78
|
+
;; first element
|
|
79
|
+
(list_lit . [(sym_lit) (package_lit)] @name) @reference.call
|
|
80
|
+
|
|
81
|
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
82
|
+
;;; classes
|
|
83
|
+
|
|
84
|
+
(list_lit . [(sym_lit) (package_lit)] @ignore
|
|
85
|
+
. [(sym_lit) (package_lit)] @name
|
|
86
|
+
(#match? @ignore "(?i)^(cl:)?defclass$")
|
|
87
|
+
) @definition.class
|
|
88
|
+
|
|
89
|
+
(list_lit . [(sym_lit) (package_lit)] @ignore
|
|
90
|
+
. (quoting_lit [(sym_lit) (package_lit)] @name)
|
|
91
|
+
(#match? @ignore "(?i)^(cl:)?make-instance$")
|
|
92
|
+
) @reference.class
|
|
93
|
+
|
|
94
|
+
;;; TODO:
|
|
95
|
+
;; - @reference.class for base classes
|
|
96
|
+
|
|
97
|
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
98
|
+
;;; TODO:
|
|
99
|
+
;; - Symbols referenced in defpackage
|
|
100
|
+
;;
|
|
101
|
+
;; (defpackage ...
|
|
102
|
+
;; (:export (symbol-a :symbol-b #:symbol-c "SYMBOL-D")))
|
|
103
|
+
;;
|
|
104
|
+
;; The goal is to allow quick navigation from the API
|
|
105
|
+
;; overview in the form of defpackage, to the definition
|
|
106
|
+
;; where user can read parameters, docstring, ect.
|
|
107
|
+
;; - The @name must not include the colon, or sharpsign colon, quotes,
|
|
108
|
+
;; just symbol-a, symbol-b, symbol-c, sybmol-d
|
|
109
|
+
;; - Downcase the names specified as stirng literals?
|
|
110
|
+
;; ("SYMBOL-D" -> symbol-d)
|
|
111
|
+
;; - We don't know if the exported symbol is a function, variable,
|
|
112
|
+
;; class or something else. The oficial doc
|
|
113
|
+
;; (https://tree-sitter.github.io/tree-sitter/code-navigation-systems)
|
|
114
|
+
;; does not even suggest a tag for variable reference.
|
|
115
|
+
;; (Although in practice, the `tree-sitter tags` command
|
|
116
|
+
;; allows any @reference.* and @definition.* tags)
|
|
117
|
+
;; Probably it's better to just use @reference.call for all
|
|
118
|
+
;; the symbols in the :export clause.
|
|
119
|
+
;;
|
|
120
|
+
;; - The same for the export function call:
|
|
121
|
+
;;
|
|
122
|
+
;; (export '(symbol-a :symbol-b #:symbol-c "SYMBOL-D"))
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
; Keywords
|
|
2
|
+
[
|
|
3
|
+
"if"
|
|
4
|
+
"then"
|
|
5
|
+
"else"
|
|
6
|
+
"let"
|
|
7
|
+
"in"
|
|
8
|
+
] @keyword.control.elm
|
|
9
|
+
(case) @keyword.control.elm
|
|
10
|
+
(of) @keyword.control.elm
|
|
11
|
+
|
|
12
|
+
(colon) @keyword.other.elm
|
|
13
|
+
(backslash) @keyword.other.elm
|
|
14
|
+
(as) @keyword.other.elm
|
|
15
|
+
(port) @keyword.other.elm
|
|
16
|
+
(exposing) @keyword.other.elm
|
|
17
|
+
(alias) @keyword.other.elm
|
|
18
|
+
(infix) @keyword.other.elm
|
|
19
|
+
|
|
20
|
+
(arrow) @keyword.operator.arrow.elm
|
|
21
|
+
|
|
22
|
+
(port) @keyword.other.port.elm
|
|
23
|
+
|
|
24
|
+
(type_annotation(lower_case_identifier) @function.elm)
|
|
25
|
+
(port_annotation(lower_case_identifier) @function.elm)
|
|
26
|
+
(function_declaration_left(lower_case_identifier) @function.elm)
|
|
27
|
+
(function_call_expr target: (value_expr) @function.elm)
|
|
28
|
+
|
|
29
|
+
(field_access_expr(value_expr(value_qid)) @local.function.elm)
|
|
30
|
+
(lower_pattern) @local.function.elm
|
|
31
|
+
(record_base_identifier) @local.function.elm
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
(operator_identifier) @keyword.operator.elm
|
|
35
|
+
(eq) @keyword.operator.assignment.elm
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
"(" @punctuation.section.braces
|
|
39
|
+
")" @punctuation.section.braces
|
|
40
|
+
|
|
41
|
+
"|" @keyword.other.elm
|
|
42
|
+
"," @punctuation.separator.comma.elm
|
|
43
|
+
|
|
44
|
+
(import) @meta.import.elm
|
|
45
|
+
(module) @keyword.other.elm
|
|
46
|
+
|
|
47
|
+
(number_constant_expr) @constant.numeric.elm
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
(type) @keyword.type.elm
|
|
51
|
+
|
|
52
|
+
(type_declaration(upper_case_identifier) @storage.type.elm)
|
|
53
|
+
(type_ref) @storage.type.elm
|
|
54
|
+
(type_alias_declaration name: (upper_case_identifier) @storage.type.elm)
|
|
55
|
+
|
|
56
|
+
(union_variant(upper_case_identifier) @union.elm)
|
|
57
|
+
(union_pattern) @union.elm
|
|
58
|
+
(value_expr(upper_case_qid(upper_case_identifier)) @union.elm)
|
|
59
|
+
|
|
60
|
+
; comments
|
|
61
|
+
(line_comment) @comment.elm
|
|
62
|
+
(block_comment) @comment.elm
|
|
63
|
+
|
|
64
|
+
; strings
|
|
65
|
+
(string_escape) @character.escape.elm
|
|
66
|
+
|
|
67
|
+
(open_quote) @string.elm
|
|
68
|
+
(close_quote) @string.elm
|
|
69
|
+
(regular_string_part) @string.elm
|
|
70
|
+
|
|
71
|
+
(open_char) @char.elm
|
|
72
|
+
(close_char) @char.elm
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
; glsl
|
|
76
|
+
(glsl_content) @source.glsl
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
(value_declaration) @local.scope
|
|
3
|
+
(type_alias_declaration) @local.scope
|
|
4
|
+
(type_declaration) @local.scope
|
|
5
|
+
(type_annotation) @local.scope
|
|
6
|
+
(port_annotation) @local.scope
|
|
7
|
+
(infix_declaration) @local.scope
|
|
8
|
+
(let_in_expr) @local.scope
|
|
9
|
+
|
|
10
|
+
(function_declaration_left (lower_pattern (lower_case_identifier)) @local.definition)
|
|
11
|
+
(function_declaration_left (lower_case_identifier) @local.definition)
|
|
12
|
+
|
|
13
|
+
(value_expr(value_qid(upper_case_identifier)) @local.reference)
|
|
14
|
+
(value_expr(value_qid(lower_case_identifier)) @local.reference)
|
|
15
|
+
(type_ref (upper_case_qid) @local.reference)
|
package/out/elm/tags.scm
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
(value_declaration (function_declaration_left (lower_case_identifier) @name)) @definition.function
|
|
2
|
+
|
|
3
|
+
(function_call_expr (value_expr (value_qid) @name)) @reference.function
|
|
4
|
+
(exposed_value (lower_case_identifier) @name) @reference.function
|
|
5
|
+
(type_annotation ((lower_case_identifier) @name) (colon)) @reference.function
|
|
6
|
+
|
|
7
|
+
(type_declaration ((upper_case_identifier) @name) ) @definition.type
|
|
8
|
+
|
|
9
|
+
(type_ref (upper_case_qid (upper_case_identifier) @name)) @reference.type
|
|
10
|
+
(exposed_type (upper_case_identifier) @name) @reference.type
|
|
11
|
+
|
|
12
|
+
(type_declaration (union_variant (upper_case_identifier) @name)) @definition.union
|
|
13
|
+
|
|
14
|
+
(value_expr (upper_case_qid (upper_case_identifier) @name)) @reference.union
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
(module_declaration
|
|
18
|
+
(upper_case_qid (upper_case_identifier)) @name
|
|
19
|
+
) @definition.module
|
|
Binary file
|
|
File without changes
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
;; Copyright (c) Facebook, Inc. and its affiliates.
|
|
2
|
+
;;
|
|
3
|
+
;; Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
;; you may not use this file except in compliance with the License.
|
|
5
|
+
;; You may obtain a copy of the License at
|
|
6
|
+
;;
|
|
7
|
+
;; http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
;;
|
|
9
|
+
;; Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
;; distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
;; See the License for the specific language governing permissions and
|
|
13
|
+
;; limitations under the License.
|
|
14
|
+
;; ---------------------------------------------------------------------
|
|
15
|
+
|
|
16
|
+
;; Based initially on the contents of https://github.com/WhatsApp/tree-sitter-erlang/issues/2 by @Wilfred
|
|
17
|
+
;; and https://github.com/the-mikedavis/tree-sitter-erlang/blob/main/queries/highlights.scm
|
|
18
|
+
;;
|
|
19
|
+
;; The tests are also based on those in
|
|
20
|
+
;; https://github.com/the-mikedavis/tree-sitter-erlang/tree/main/test/highlight
|
|
21
|
+
;;
|
|
22
|
+
|
|
23
|
+
;; Last match wins in this file.
|
|
24
|
+
;; As of https://github.com/tree-sitter/tree-sitter/blob/master/CHANGELOG.md#breaking-1
|
|
25
|
+
|
|
26
|
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
27
|
+
;; Primitive types
|
|
28
|
+
(string) @string
|
|
29
|
+
(char) @constant
|
|
30
|
+
(integer) @number
|
|
31
|
+
(var) @variable
|
|
32
|
+
(atom) @string.special.symbol
|
|
33
|
+
|
|
34
|
+
;;; Comments
|
|
35
|
+
((var) @comment.discard
|
|
36
|
+
(#match? @comment.discard "^_"))
|
|
37
|
+
|
|
38
|
+
(dotdotdot) @comment.discard
|
|
39
|
+
(comment) @comment
|
|
40
|
+
|
|
41
|
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
42
|
+
;; Functions
|
|
43
|
+
(fa fun: (atom) @function)
|
|
44
|
+
(type_name name: (atom) @function)
|
|
45
|
+
(call expr: (atom) @function)
|
|
46
|
+
(function_clause name: (atom) @function)
|
|
47
|
+
(internal_fun fun: (atom) @function)
|
|
48
|
+
|
|
49
|
+
;; This is a fudge, we should check that the operator is '/'
|
|
50
|
+
;; But our grammar does not (currently) provide it
|
|
51
|
+
(binary_op_expr lhs: (atom) @function rhs: (integer))
|
|
52
|
+
|
|
53
|
+
;; Others
|
|
54
|
+
(remote_module module: (atom) @module)
|
|
55
|
+
(remote fun: (atom) @function)
|
|
56
|
+
(macro_call_expr name: (var) @constant)
|
|
57
|
+
(macro_call_expr name: (var) @keyword.directive args: (_) )
|
|
58
|
+
(macro_call_expr name: (atom) @keyword.directive)
|
|
59
|
+
(record_field_name name: (atom) @property)
|
|
60
|
+
(record_name name: (atom) @type)
|
|
61
|
+
|
|
62
|
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
63
|
+
;; Attributes
|
|
64
|
+
|
|
65
|
+
;; module attribute
|
|
66
|
+
(module_attribute
|
|
67
|
+
name: (atom) @module)
|
|
68
|
+
|
|
69
|
+
;; behaviour
|
|
70
|
+
(behaviour_attribute name: (atom) @module)
|
|
71
|
+
|
|
72
|
+
;; export
|
|
73
|
+
|
|
74
|
+
;; Import attribute
|
|
75
|
+
(import_attribute
|
|
76
|
+
module: (atom) @module)
|
|
77
|
+
|
|
78
|
+
;; export_type
|
|
79
|
+
|
|
80
|
+
;; optional_callbacks
|
|
81
|
+
|
|
82
|
+
;; compile
|
|
83
|
+
(compile_options_attribute
|
|
84
|
+
options: (tuple
|
|
85
|
+
expr: (atom)
|
|
86
|
+
expr: (list
|
|
87
|
+
exprs: (binary_op_expr
|
|
88
|
+
lhs: (atom)
|
|
89
|
+
rhs: (integer)))))
|
|
90
|
+
|
|
91
|
+
;; file attribute
|
|
92
|
+
|
|
93
|
+
;; record
|
|
94
|
+
(record_decl name: (atom) @type)
|
|
95
|
+
(record_decl name: (macro_call_expr name: (var) @constant))
|
|
96
|
+
(record_field name: (atom) @property)
|
|
97
|
+
|
|
98
|
+
;; type alias
|
|
99
|
+
|
|
100
|
+
;; opaque
|
|
101
|
+
|
|
102
|
+
;; Spec attribute
|
|
103
|
+
(spec fun: (atom) @function)
|
|
104
|
+
(spec
|
|
105
|
+
module: (module name: (atom) @module)
|
|
106
|
+
fun: (atom) @function)
|
|
107
|
+
|
|
108
|
+
;; callback
|
|
109
|
+
(callback fun: (atom) @function)
|
|
110
|
+
|
|
111
|
+
;; wild attribute
|
|
112
|
+
(wild_attribute name: (attr_name name: (atom) @keyword))
|
|
113
|
+
|
|
114
|
+
;; fun decl
|
|
115
|
+
|
|
116
|
+
;; include/include_lib
|
|
117
|
+
|
|
118
|
+
;; ifdef/ifndef
|
|
119
|
+
(pp_ifdef name: (_) @keyword.directive)
|
|
120
|
+
(pp_ifndef name: (_) @keyword.directive)
|
|
121
|
+
|
|
122
|
+
;; define
|
|
123
|
+
(pp_define
|
|
124
|
+
lhs: (macro_lhs
|
|
125
|
+
name: (var) @constant))
|
|
126
|
+
(pp_define
|
|
127
|
+
lhs: (macro_lhs
|
|
128
|
+
name: (_) @keyword.directive
|
|
129
|
+
args: (var_args args: (var))))
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
133
|
+
;; Reserved words
|
|
134
|
+
[ "after"
|
|
135
|
+
"and"
|
|
136
|
+
"band"
|
|
137
|
+
"begin"
|
|
138
|
+
"behavior"
|
|
139
|
+
"behaviour"
|
|
140
|
+
"bnot"
|
|
141
|
+
"bor"
|
|
142
|
+
"bsl"
|
|
143
|
+
"bsr"
|
|
144
|
+
"bxor"
|
|
145
|
+
"callback"
|
|
146
|
+
"case"
|
|
147
|
+
"catch"
|
|
148
|
+
"compile"
|
|
149
|
+
"define"
|
|
150
|
+
"div"
|
|
151
|
+
"elif"
|
|
152
|
+
"else"
|
|
153
|
+
"end"
|
|
154
|
+
"endif"
|
|
155
|
+
"export"
|
|
156
|
+
"export_type"
|
|
157
|
+
"file"
|
|
158
|
+
"fun"
|
|
159
|
+
"if"
|
|
160
|
+
"ifdef"
|
|
161
|
+
"ifndef"
|
|
162
|
+
"import"
|
|
163
|
+
"include"
|
|
164
|
+
"include_lib"
|
|
165
|
+
"module"
|
|
166
|
+
"of"
|
|
167
|
+
"opaque"
|
|
168
|
+
"optional_callbacks"
|
|
169
|
+
"or"
|
|
170
|
+
"receive"
|
|
171
|
+
"record"
|
|
172
|
+
"spec"
|
|
173
|
+
"try"
|
|
174
|
+
"type"
|
|
175
|
+
"undef"
|
|
176
|
+
"unit"
|
|
177
|
+
"when"
|
|
178
|
+
"xor"] @keyword
|
|
179
|
+
|
|
180
|
+
["andalso" "orelse"] @keyword.operator
|
|
181
|
+
|
|
182
|
+
;; Punctuation
|
|
183
|
+
["," "." ";"] @punctuation.delimiter
|
|
184
|
+
["(" ")" "{" "}" "[" "]" "<<" ">>"] @punctuation.bracket
|
|
185
|
+
|
|
186
|
+
;; Operators
|
|
187
|
+
["!"
|
|
188
|
+
"->"
|
|
189
|
+
"<-"
|
|
190
|
+
"#"
|
|
191
|
+
"::"
|
|
192
|
+
":>"
|
|
193
|
+
"|"
|
|
194
|
+
":"
|
|
195
|
+
"="
|
|
196
|
+
"||"
|
|
197
|
+
|
|
198
|
+
"+"
|
|
199
|
+
"-"
|
|
200
|
+
"bnot"
|
|
201
|
+
"not"
|
|
202
|
+
|
|
203
|
+
"/"
|
|
204
|
+
"*"
|
|
205
|
+
"div"
|
|
206
|
+
"rem"
|
|
207
|
+
"band"
|
|
208
|
+
"and"
|
|
209
|
+
|
|
210
|
+
"+"
|
|
211
|
+
"-"
|
|
212
|
+
"bor"
|
|
213
|
+
"bxor"
|
|
214
|
+
"bsl"
|
|
215
|
+
"bsr"
|
|
216
|
+
"or"
|
|
217
|
+
"xor"
|
|
218
|
+
|
|
219
|
+
"++"
|
|
220
|
+
"--"
|
|
221
|
+
|
|
222
|
+
"=="
|
|
223
|
+
"/="
|
|
224
|
+
"=<"
|
|
225
|
+
"<"
|
|
226
|
+
">="
|
|
227
|
+
">"
|
|
228
|
+
"=:="
|
|
229
|
+
"=/="
|
|
230
|
+
] @operator
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|