Skip to content

Commit 44f101e

Browse files
committed
Initial commit
Signed-off-by: egibs <[email protected]>
1 parent ae0dbdc commit 44f101e

File tree

7 files changed

+160
-1
lines changed

7 files changed

+160
-1
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,7 @@ Cargo.lock
1818
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
1919
# and can be added to the global gitignore or merged into this file. For a more nuclear
2020
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
21-
#.idea/
21+
#.idea/
22+
23+
# Grammars
24+
grammars/

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
# yara.zed
22
Yara language extension for Zed.
3+
4+
Example (using the `Ayu Mirage` theme):
5+
![Yara syntax highlighting in Zed](example.png)

example.png

189 KB
Loading

example.yara

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import "math"
2+
3+
private global rule test: tag1 {
4+
strings:
5+
$hello = "hello world"
6+
condition:
7+
all of them
8+
}
9+
10+
private rule test2: tag2 tag3 tag4 tag5 {
11+
strings:
12+
$hello = "hello world"
13+
$ = "test"
14+
$ = "test2"
15+
$ = "test3"
16+
condition:
17+
filesize > 1MB and all of them
18+
}
19+
20+
private rule test3: tag4 tag5 {
21+
strings:
22+
$hello = "hello world"
23+
$test = "test"
24+
$ = "test2"
25+
$ = "test3"
26+
condition:
27+
filesize > 2MB and any of them
28+
}

extension.toml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
id = "yara"
2+
name = "Yara"
3+
version = "0.0.1"
4+
schema_version = 1
5+
authors = ["egibs <[email protected]>"]
6+
description = "Yara syntax highlighting for Zed."
7+
repository = "https://github.com/egibs/yara-zed"
8+
9+
[grammars.yara]
10+
repository = "https://github.com/egibs/tree-sitter-yara.git"
11+
commit = "ade4c74fdef17549555694c42621eeac9eaba0f8"

languages/yara/config.toml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name = "Yara"
2+
grammar = "yara"
3+
path_suffixes = ["yar", "yara"]
4+
line_comments = ["//"]
5+
brackets = [
6+
{ start = "{", end = "}", close = true, newline = true },
7+
{ start = "[", end = "]", close = true, newline = true },
8+
{ start = "\"", end = "\"", close = true, newline = false, not_in = [
9+
"string",
10+
] },
11+
]

languages/yara/highlights.scm

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
; Keywords
2+
[
3+
"rule"
4+
"global"
5+
"private"
6+
"import"
7+
"include"
8+
"strings"
9+
"condition"
10+
"meta"
11+
] @keyword
12+
13+
; Keywords (condition)
14+
[
15+
"and"
16+
"or"
17+
"not"
18+
"matches"
19+
"contains"
20+
"icontains"
21+
"imatches"
22+
"startswith"
23+
"istartswith"
24+
"endswith"
25+
"iendswith"
26+
"for"
27+
"of"
28+
"in"
29+
"all"
30+
"any"
31+
"them"
32+
] @keyword.operator
33+
34+
; Built-in identifiers
35+
(filesize) @function.builtin
36+
(entrypoint) @function.builtin
37+
38+
; String modifiers
39+
[
40+
"ascii"
41+
"wide"
42+
"nocase"
43+
"fullword"
44+
"xor"
45+
"base64"
46+
"base64wide"
47+
] @keyword.modifier
48+
49+
; Rule names
50+
(rule_definition
51+
name: (identifier) @function)
52+
53+
; Tags
54+
(tag_list
55+
[(identifier) (tag)] @tag)
56+
57+
; Meta definitions
58+
(meta_definition
59+
key: (identifier) @property)
60+
61+
; String identifiers
62+
(string_identifier
63+
(identifier)? @string.special)
64+
65+
; Constants
66+
(boolean_literal) @constant.builtin
67+
68+
(integer_literal) @constant.numeric
69+
(size_unit) @constant.numeric
70+
71+
; Strings
72+
(double_quoted_string) @string
73+
(single_quoted_string) @string
74+
(escape_sequence) @string.escape
75+
76+
; Hex strings
77+
(hex_string) @string.special
78+
(hex_byte) @constant.numeric
79+
(hex_wildcard) @constant.builtin
80+
81+
; Regex strings
82+
(regex_string) @string.regexp
83+
(pattern) @string.regexp
84+
85+
; Operators
86+
[
87+
">"
88+
"<"
89+
"=="
90+
"<="
91+
">="
92+
"!="
93+
"+"
94+
"-"
95+
"*"
96+
"\\"
97+
"%"
98+
] @operator
99+
100+
[":" "=" "{" "}" "(" ")" "[" "]" "$" "#" "@" "!" ".." "|" ","] @punctuation.delimiter
101+
102+
; Comments
103+
(comment) @comment

0 commit comments

Comments
 (0)