on master help sign in
feat(lang): add hare language support (#2289)

Co-authored-by: Mehdi Katranji <hello@mek.yt>

commit1a3d6252b9d1a411df8ea27ee04960f599c35a6b authormeak <mehdi.katranji@outlook.com> dateTue 26 Apr 2022, 21:55 (5 years ago) parent773736b
5 files changed+213
book/src/generated/lang-support.md+1 languages.toml+13 runtime/queries/hare/highlights.scm+158 runtime/queries/hare/indents.scm+21 runtime/queries/hare/locals.scm+20
book/src/generated/lang-support.md+1
@@ -27,6 +27,7 @@
2727| gomod | ✓ | | | `gopls` |
2828| gowork | ✓ | | | `gopls` |
2929| graphql | ✓ | | | |
30+| hare | ✓ | | ✓ | |
3031| haskell | ✓ | | | `haskell-language-server-wrapper` |
3132| hcl | ✓ | | ✓ | `terraform-ls` |
3233| heex | ✓ | | | |
languages.toml+13
@@ -1249,3 +1249,16 @@ language-server = { command = "vala-language-server" }
12491249[[grammar]]
12501250name = "vala"
12511251source = { git = "https://github.com/vala-lang/tree-sitter-vala", rev = "c9eea93ba2ec4ec1485392db11945819779745b3" }
1252+
1253+[[language]]
1254+name = "hare"
1255+scope = "source.hare"
1256+injection-regex = "hare"
1257+file-types = ["ha"]
1258+roots = []
1259+comment-token = "//"
1260+indent = { tab-width = 4, unit = "\t" }
1261+
1262+[[grammar]]
1263+name = "hare"
1264+source = { git = "https://git.sr.ht/~ecmma/tree-sitter-hare", rev = "bc26a6a949f2e0d98b7bfc437d459b250900a165" }
runtime/queries/hare/highlights.scmnew file+158
@@ -0,0 +1,158 @@
1+[
2+ "f32"
3+ "f64"
4+ "i16"
5+ "i32"
6+ "i64"
7+ "i8"
8+ "int"
9+ "rune"
10+ "str"
11+ "u16"
12+ "u32"
13+ "u64"
14+ "u8"
15+ "uint"
16+ "uintptr"
17+ "void"
18+] @type
19+
20+
21+[
22+ "else"
23+ "if"
24+ "match"
25+ "switch"
26+] @keyword.control.conditional
27+
28+[
29+ "export"
30+ "use"
31+] @keyword.control.import
32+
33+[
34+ "continue"
35+ "for"
36+ "break"
37+] @keyword.control.repeat
38+
39+"return" @keyword.control.return
40+
41+[
42+ "abort"
43+ "assert"
44+] @keyword.control.exception
45+
46+[
47+ "def"
48+ "fn"
49+] @keyword.function
50+
51+[
52+ "alloc"
53+ "append"
54+ "as"
55+ "bool"
56+ "char"
57+ "const"
58+ "defer"
59+ "delete"
60+ "enum"
61+ "free"
62+ "is"
63+ "len"
64+ "let"
65+ "match"
66+ "nullable"
67+ "offset"
68+ "size"
69+ "static"
70+ "struct"
71+ "type"
72+ "union"
73+] @keyword
74+
75+[
76+ "."
77+ "!"
78+ "~"
79+ "?"
80+ "*"
81+ "/"
82+ "%"
83+ "+"
84+ "-"
85+ "<<"
86+ ">>"
87+ "::"
88+ "<"
89+ "<="
90+ ">"
91+ ">="
92+ "=="
93+ "!="
94+ "&"
95+ "|"
96+ "^"
97+ "&&"
98+ "||"
99+ "="
100+ "+="
101+ "-="
102+ "*="
103+ "/="
104+ "%="
105+ "&="
106+ "|="
107+ "<<="
108+ ">>="
109+ "^="
110+ "=>"
111+] @operator
112+
113+[
114+ "("
115+ ")"
116+ "["
117+ "]"
118+ ")"
119+ "{"
120+ "}"
121+] @punctuation.bracket
122+
123+[
124+ ":"
125+ ";"
126+] @punctuation.delimiter
127+
128+"..." @special
129+
130+(comment) @comment
131+
132+[
133+ "false"
134+ "null"
135+ "true"
136+] @constant.builtin
137+
138+(string_constant) @string
139+(escape_sequence) @constant.character.escape
140+(rune_constant) @string
141+(integer_constant) @constant.numeric.integer
142+(floating_constant) @constant.numeric.float
143+
144+(call_expression
145+ (postfix_expression) @function)
146+
147+(function_declaration
148+ name: (identifier) @function)
149+
150+(parameter (name) @variable.parameter)
151+
152+(field_access_expression
153+ selector: (name) @variable.other.member)
154+(decl_attr) @special
155+(fndec_attrs) @special
156+
157+(identifier) @variable
158+
runtime/queries/hare/indents.scmnew file+21
@@ -0,0 +1,21 @@
1+[
2+ (struct_union_fields)
3+ (expression_list)
4+] @indent
5+
6+[
7+ "case"
8+ "}"
9+ "]"
10+ ")"
11+] @outdent
12+
13+; [
14+; "{"
15+; "}"
16+; ] @branch
17+
18+; [
19+; (comment)
20+; ] @ignore
21+
runtime/queries/hare/locals.scmnew file+20
@@ -0,0 +1,20 @@
1+(unit) @local.scope
2+
3+(function_declaration) @local.scope
4+
5+(global_binding
6+ (identifier) @local.definition)
7+(constant_binding
8+ (identifier) @local.definition)
9+(type_bindings
10+ (identifier) @local.definition)
11+
12+(function_declaration
13+ (prototype
14+ (parameter_list
15+ (parameters
16+ (parameter
17+ (name) @local.definition)))))
18+
19+(identifier) @local.reference
20+