Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(languages): add odin language #2399

Merged
merged 3 commits into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1303,3 +1303,16 @@ indent = { tab-width = 2, unit = " " }
[[grammar]]
name = "cpon"
source = { git = "https://github.com/fvacek/tree-sitter-cpon", rev = "11ba46a4de3eb86934003133099c9963a60f9687" }

[[language]]
name = "odin"
auto-format = false
scope = "source.odin"
file-types = ["odin"]
roots = []
comment-token = "//"
indent = { tab-width = 4, unit = " " }

[[grammar]]
name = "odin"
source = { git = "https://github.com/MineBill/tree-sitter-odin", rev = "da885f4a387f169b9b69fe0968259ee257a8f69a" }
140 changes: 140 additions & 0 deletions runtime/queries/odin/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
; Function calls

(call_expression
function: (identifier) @function)

(call_expression
function: (selector_expression
field: (field_identifier) @function))


; ; Function definitions

(function_declaration
name: (identifier) @function)

(proc_group
(identifier) @function)

; ; Identifiers

(type_identifier) @type
(field_identifier) @property
RobWalt marked this conversation as resolved.
Show resolved Hide resolved
(identifier) @variable

(const_declaration
(identifier) @constant)
(const_declaration_with_type
(identifier) @constant)

"any" @type

(directive_identifier) @constant

; ; Operators

[
"?"
"-"
"-="
":="
"!"
"!="
"*"
"*"
"*="
"/"
"/="
"&"
"&&"
"&="
"%"
"%="
"^"
"+"
"+="
"<-"
"<"
"<<"
"<<="
"<="
"="
"=="
">"
">="
">>"
">>="
"|"
"|="
"||"
"~"
".."
"..<"
"..="
"::"
] @operator

; ; Keywords

[
; "asm"
"auto_cast"
; "bit_set"
"cast"
; "context"
; "or_else"
; "or_return"
"in"
; "not_in"
"distinct"
"foreign"
"transmute"
; "typeid"

"break"
"case"
"continue"
"defer"
"else"
"using"
"when"
"where"
"fallthrough"
"for"
"proc"
"if"
"import"
"map"
"package"
"return"
"struct"
"union"
"enum"
"switch"
"dynamic"
] @keyword

; ; Literals

[
(interpreted_string_literal)
(raw_string_literal)
(rune_literal)
] @string

(escape_sequence) @escape
RobWalt marked this conversation as resolved.
Show resolved Hide resolved

[
(int_literal)
(float_literal)
(imaginary_literal)
] @number
RobWalt marked this conversation as resolved.
Show resolved Hide resolved

[
(true)
(false)
(nil)
(undefined)
] @constant
RobWalt marked this conversation as resolved.
Show resolved Hide resolved

(comment) @comment