on master help sign in
feat(languages): add odin language (#2399)
commit495ba40eafe84f048e56b3d958a7727751f3aa99 authorRobert Walter <26892280+RobWalt@users.noreply.github.com> dateThu 5 May 2022, 19:09 (4 years ago) parent2f240b0
3 files changed+155
book/src/generated/lang-support.md+1 languages.toml+13 runtime/queries/odin/highlights.scm+141
book/src/generated/lang-support.md+1
@@ -59,6 +59,7 @@
5959| nu | ✓ | | | |
6060| ocaml | ✓ | | ✓ | `ocamllsp` |
6161| ocaml-interface | ✓ | | | `ocamllsp` |
62+| odin | ✓ | | | |
6263| org | ✓ | | | |
6364| perl | ✓ | ✓ | ✓ | |
6465| php | ✓ | ✓ | ✓ | `intelephense` |
languages.toml+13
@@ -1329,3 +1329,16 @@ indent = { tab-width = 2, unit = " " }
13291329[[grammar]]
13301330name = "cpon"
13311331source = { git = "https://github.com/fvacek/tree-sitter-cpon", rev = "11ba46a4de3eb86934003133099c9963a60f9687" }
1332+
1333+[[language]]
1334+name = "odin"
1335+auto-format = false
1336+scope = "source.odin"
1337+file-types = ["odin"]
1338+roots = []
1339+comment-token = "//"
1340+indent = { tab-width = 4, unit = " " }
1341+
1342+[[grammar]]
1343+name = "odin"
1344+source = { git = "https://github.com/MineBill/tree-sitter-odin", rev = "da885f4a387f169b9b69fe0968259ee257a8f69a" }
runtime/queries/odin/highlights.scmnew file+141
@@ -0,0 +1,141 @@
1+; Function calls
2+
3+(call_expression
4+ function: (identifier) @function)
5+
6+(call_expression
7+ function: (selector_expression
8+ field: (field_identifier) @function))
9+
10+
11+; ; Function definitions
12+
13+(function_declaration
14+ name: (identifier) @function)
15+
16+(proc_group
17+ (identifier) @function)
18+
19+; ; Identifiers
20+
21+(type_identifier) @type
22+(field_identifier) @variable.other.member
23+(identifier) @variable
24+
25+(const_declaration
26+ (identifier) @constant)
27+(const_declaration_with_type
28+ (identifier) @constant)
29+
30+"any" @type
31+
32+(directive_identifier) @constant
33+
34+; ; Operators
35+
36+[
37+ "?"
38+ "-"
39+ "-="
40+ ":="
41+ "!"
42+ "!="
43+ "*"
44+ "*"
45+ "*="
46+ "/"
47+ "/="
48+ "&"
49+ "&&"
50+ "&="
51+ "%"
52+ "%="
53+ "^"
54+ "+"
55+ "+="
56+ "<-"
57+ "<"
58+ "<<"
59+ "<<="
60+ "<="
61+ "="
62+ "=="
63+ ">"
64+ ">="
65+ ">>"
66+ ">>="
67+ "|"
68+ "|="
69+ "||"
70+ "~"
71+ ".."
72+ "..<"
73+ "..="
74+ "::"
75+] @operator
76+
77+; ; Keywords
78+
79+[
80+ ; "asm"
81+ "auto_cast"
82+ ; "bit_set"
83+ "cast"
84+ ; "context"
85+ ; "or_else"
86+ ; "or_return"
87+ "in"
88+ ; "not_in"
89+ "distinct"
90+ "foreign"
91+ "transmute"
92+ ; "typeid"
93+
94+ "break"
95+ "case"
96+ "continue"
97+ "defer"
98+ "else"
99+ "using"
100+ "when"
101+ "where"
102+ "fallthrough"
103+ "for"
104+ "proc"
105+ "if"
106+ "import"
107+ "map"
108+ "package"
109+ "return"
110+ "struct"
111+ "union"
112+ "enum"
113+ "switch"
114+ "dynamic"
115+] @keyword
116+
117+; ; Literals
118+
119+[
120+ (interpreted_string_literal)
121+ (raw_string_literal)
122+ (rune_literal)
123+] @string
124+
125+(escape_sequence) @constant.character.escape
126+
127+(int_literal) @constant.numeric.integer
128+(float_literal) @constant.numeric.float
129+(imaginary_literal) @constant.numeric
130+
131+[
132+ (true)
133+ (false)
134+] @constant.builtin.boolean
135+
136+[
137+ (nil)
138+ (undefined)
139+] @constant.builtin
140+
141+(comment) @comment.line