on master help sign in
add tree-sitter-regex (#1362)
a8fd33aMichael Davis
.gitmodules+4
@@ -190,3 +190,7 @@
190 path = helix-syntax/languages/tree-sitter-git-rebase
190 path = helix-syntax/languages/tree-sitter-git-rebase
191 url = https://github.com/the-mikedavis/tree-sitter-git-rebase.git
191 url = https://github.com/the-mikedavis/tree-sitter-git-rebase.git
192 shallow = true
192 shallow = true
193+[submodule "helix-syntax/languages/tree-sitter-regex"]
194+ path = helix-syntax/languages/tree-sitter-regex
195+ url = https://github.com/tree-sitter/tree-sitter-regex.git
196+ shallow = true
book/src/generated/lang-support.md+1
@@ -38,6 +38,7 @@
38| protobuf | ✓ | | ✓ | |
38| protobuf | ✓ | | ✓ | |
39| python | ✓ | ✓ | ✓ | `pylsp` |
39| python | ✓ | ✓ | ✓ | `pylsp` |
40| racket | | | | `racket` |
40| racket | | | | `racket` |
41+| regex | ✓ | | | |
41| ruby | ✓ | | ✓ | `solargraph` |
42| ruby | ✓ | | ✓ | `solargraph` |
42| rust | ✓ | ✓ | ✓ | `rust-analyzer` |
43| rust | ✓ | ✓ | ✓ | `rust-analyzer` |
43| scala | ✓ | | ✓ | `metals` |
44| scala | ✓ | | ✓ | `metals` |
helix-syntax/languages/tree-sitter-regexnew file+1

Submodule changed.

languages.toml+7
@@ -530,3 +530,10 @@ file-types = ["git-rebase-todo"]
530injection-regex = "git-rebase"
530injection-regex = "git-rebase"
531comment-token = "#"
531comment-token = "#"
532indent = { tab-width = 2, unit = " " }
532indent = { tab-width = 2, unit = " " }
533+
534+[[language]]
535+name = "regex"
536+scope = "source.regex"
537+injection-regex = "regex"
538+file-types = ["regex"]
539+roots = []
runtime/queries/elixir/injections.scm+7
@@ -1,2 +1,9 @@
1((comment) @injection.content
1((comment) @injection.content
2 (#set! injection.language "comment"))
2 (#set! injection.language "comment"))
3+
4+((sigil
5+ (sigil_name) @_sigil_name
6+ (quoted_content) @injection.content)
7+ (#match? @_sigil_name "^(r|R)$")
8+ (#set! injection.language "regex")
9+ (#set! injection.combined))
runtime/queries/regex/highlights.scmnew file+53
@@ -0,0 +1,53 @@
1+; upstream: https://github.com/tree-sitter/tree-sitter-regex/blob/e1cfca3c79896ff79842f057ea13e529b66af636/queries/highlights.scm
2+
3+[
4+ "("
5+ ")"
6+ "(?"
7+ "(?:"
8+ "(?<"
9+ ">"
10+ "["
11+ "]"
12+ "{"
13+ "}"
14+] @punctuation.bracket
15+
16+[
17+ "*"
18+ "+"
19+ "|"
20+ "="
21+ "<="
22+ "!"
23+ "<!"
24+ "?"
25+] @operator
26+
27+[
28+ (identity_escape)
29+ (control_letter_escape)
30+ (character_class_escape)
31+ (control_escape)
32+ (start_assertion)
33+ (end_assertion)
34+ (boundary_assertion)
35+ (non_boundary_assertion)
36+] @constant.character.escape
37+
38+(group_name) @property
39+
40+(count_quantifier
41+ [
42+ (decimal_digits) @constant.numeric
43+ "," @punctuation.delimiter
44+ ])
45+
46+(character_class
47+ [
48+ "^" @operator
49+ (class_range "-" @operator)
50+ ])
51+
52+(class_character) @constant.character
53+(pattern_character) @string
runtime/queries/rust/injections.scm+14
@@ -10,3 +10,17 @@
10 (token_tree) @injection.content)
10 (token_tree) @injection.content)
11 (#set! injection.language "rust")
11 (#set! injection.language "rust")
12 (#set! injection.include-children))
12 (#set! injection.include-children))
13+
14+(call_expression
15+ function: (scoped_identifier
16+ path: (identifier) @_regex (#eq? @_regex "Regex")
17+ name: (identifier) @_new (#eq? @_new "new"))
18+ arguments: (arguments (raw_string_literal) @injection.content)
19+ (#set! injection.language "regex"))
20+
21+(call_expression
22+ function: (scoped_identifier
23+ path: (scoped_identifier (identifier) @_regex (#eq? @_regex "Regex") .)
24+ name: (identifier) @_new (#eq? @_new "new"))
25+ arguments: (arguments (raw_string_literal) @injection.content)
26+ (#set! injection.language "regex"))