aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmaan Qureshi <amaanq12@gmail.com>2023-05-11 03:56:12 -0400
committerAmaan Qureshi <amaanq12@gmail.com>2023-05-13 02:49:07 -0400
commit40d373adcd0c9f86d8e1beb2b2028723f288aade (patch)
treeda85be1e990f28ffcae69fb611fe9a78b4e7cd46
parentfeat(func): update highlights (diff)
downloadnvim-treesitter-40d373adcd0c9f86d8e1beb2b2028723f288aade.tar
nvim-treesitter-40d373adcd0c9f86d8e1beb2b2028723f288aade.tar.gz
nvim-treesitter-40d373adcd0c9f86d8e1beb2b2028723f288aade.tar.bz2
nvim-treesitter-40d373adcd0c9f86d8e1beb2b2028723f288aade.tar.lz
nvim-treesitter-40d373adcd0c9f86d8e1beb2b2028723f288aade.tar.xz
nvim-treesitter-40d373adcd0c9f86d8e1beb2b2028723f288aade.tar.zst
nvim-treesitter-40d373adcd0c9f86d8e1beb2b2028723f288aade.zip
feat: add Odin
-rw-r--r--README.md1
-rw-r--r--lockfile.json3
-rw-r--r--lua/nvim-treesitter/parsers.lua8
-rw-r--r--queries/odin/folds.scm7
-rw-r--r--queries/odin/highlights.scm293
-rw-r--r--queries/odin/indents.scm27
-rw-r--r--queries/odin/injections.scm1
-rw-r--r--queries/odin/locals.scm39
8 files changed, 379 insertions, 0 deletions
diff --git a/README.md b/README.md
index 1fb1830fb..9938df2c4 100644
--- a/README.md
+++ b/README.md
@@ -284,6 +284,7 @@ We are looking for maintainers to add more parsers and to write query files for
- [x] [ocaml](https://github.com/tree-sitter/tree-sitter-ocaml) (maintained by @undu)
- [x] [ocaml_interface](https://github.com/tree-sitter/tree-sitter-ocaml) (maintained by @undu)
- [x] [ocamllex](https://github.com/atom-ocaml/tree-sitter-ocamllex) (maintained by @undu)
+- [x] [odin](https://github.com/amaanq/tree-sitter-odin) (maintained by @amaanq)
- [ ] [org](https://github.com/milisims/tree-sitter-org)
- [x] [pascal](https://github.com/Isopod/tree-sitter-pascal.git) (maintained by @Isopod)
- [x] [passwd](https://github.com/ath3/tree-sitter-passwd) (maintained by @amaanq)
diff --git a/lockfile.json b/lockfile.json
index bc3bfcacf..68e46cf20 100644
--- a/lockfile.json
+++ b/lockfile.json
@@ -332,6 +332,9 @@
"ocamllex": {
"revision": "ac1d5957e719d49bd6acd27439b79843e4daf8ed"
},
+ "odin": {
+ "revision": "d165dbee27617dab2653e38737d96ede1030d14f"
+ },
"org": {
"revision": "081179c52b3e8175af62b9b91dc099d010c38770"
},
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index 2fd4b14bc..c4ed3d720 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -1010,6 +1010,14 @@ list.ocamllex = {
maintainers = { "@undu" },
}
+list.odin = {
+ install_info = {
+ url = "https://github.com/amaanq/tree-sitter-odin",
+ files = { "src/parser.c", "src/scanner.c" },
+ },
+ maintainers = { "@amaanq" },
+}
+
list.org = {
install_info = {
url = "https://github.com/milisims/tree-sitter-org",
diff --git a/queries/odin/folds.scm b/queries/odin/folds.scm
new file mode 100644
index 000000000..5367cb5f2
--- /dev/null
+++ b/queries/odin/folds.scm
@@ -0,0 +1,7 @@
+[
+ (declaration)
+ (statement)
+ (else_when_clause)
+ (else_if_clause)
+ (else_clause)
+] @fold
diff --git a/queries/odin/highlights.scm b/queries/odin/highlights.scm
new file mode 100644
index 000000000..e9ded5397
--- /dev/null
+++ b/queries/odin/highlights.scm
@@ -0,0 +1,293 @@
+; Preprocs
+
+[
+ (calling_convention)
+ (tag)
+] @preproc
+
+; Includes
+
+[
+ "import"
+ "package"
+] @include
+
+; Keywords
+
+[
+ "foreign"
+ "using"
+ "struct"
+ "enum"
+ "union"
+ "defer"
+ "cast"
+ "transmute"
+ "auto_cast"
+ "map"
+ "bit_set"
+ "matrix"
+] @keyword
+
+[
+ "proc"
+] @keyword.function
+
+[
+ "return"
+ "or_return"
+] @keyword.return
+
+[
+ "distinct"
+ "dynamic"
+] @storageclass
+
+; Conditionals
+
+[
+ "if"
+ "else"
+ "when"
+ "switch"
+ "case"
+ "where"
+ "break"
+ (fallthrough_statement)
+] @conditional
+
+((ternary_expression
+ [
+ "?"
+ ":"
+ "if"
+ "else"
+ "when"
+ ] @conditional.ternary)
+ (#set! "priority" 105))
+
+; Repeats
+
+[
+ "for"
+ "do"
+ "continue"
+] @repeat
+
+; Variables
+
+(identifier) @variable
+
+; Namespaces
+
+(package_declaration (identifier) @namespace)
+
+(import_declaration alias: (identifier) @namespace)
+
+(foreign_block (identifier) @namespace)
+
+(using_statement (identifier) @namespace)
+
+; Parameters
+
+(parameter (identifier) @parameter ":" "="? (identifier)? @constant)
+
+(default_parameter (identifier) @parameter ":=")
+
+(named_type (identifier) @parameter)
+
+(call_expression argument: (identifier) @parameter "=")
+
+; Functions
+
+(procedure_declaration (identifier) @type)
+
+(procedure_declaration (identifier) @function (procedure (block)))
+
+(procedure_declaration (identifier) @function (procedure (uninitialized)))
+
+(overloaded_procedure_declaration (identifier) @function)
+
+(call_expression function: (identifier) @function.call)
+
+; Types
+
+(type (identifier) @type)
+
+((type (identifier) @type.builtin)
+ (#any-of? @type.builtin
+ "bool" "byte" "b8" "b16" "b32" "b64"
+ "int" "i8" "i16" "i32" "i64" "i128"
+ "uint" "u8" "u16" "u32" "u64" "u128" "uintptr"
+ "i16le" "i32le" "i64le" "i128le" "u16le" "u32le" "u64le" "u128le"
+ "i16be" "i32be" "i64be" "i128be" "u16be" "u32be" "u64be" "u128be"
+ "float" "double" "f16" "f32" "f64" "f16le" "f32le" "f64le" "f16be" "f32be" "f64be"
+ "complex32" "complex64" "complex128" "complex_float" "complex_double"
+ "quaternion64" "quaternion128" "quaternion256"
+ "rune" "string" "cstring" "rawptr" "typeid" "any"))
+
+"..." @type.builtin
+
+(struct_declaration (identifier) @type "::")
+
+(enum_declaration (identifier) @type "::")
+
+(union_declaration (identifier) @type "::")
+
+(const_declaration (identifier) @type "::" [(array_type) (distinct_type) (bit_set_type) (pointer_type)])
+
+(struct . (identifier) @type)
+
+(field_type . (identifier) @namespace "." (identifier) @type)
+
+(bit_set_type (identifier) @type ";")
+
+(procedure_type (parameters (parameter (identifier) @type)))
+
+(polymorphic_parameters (identifier) @type)
+
+((identifier) @type
+ (#lua-match? @type "^[A-Z][a-zA-Z0-9]*$")
+ (#not-has-parent? @type parameter procedure_declaration))
+
+; Fields
+
+(member_expression "." (identifier) @field)
+
+(struct_type "{" (identifier) @field)
+
+(struct_field (identifier) @field "="?)
+
+(field (identifier) @field)
+
+; Constants
+
+((identifier) @constant
+ (#lua-match? @constant "^_*[A-Z][A-Z0-9_]*$")
+ (#not-has-parent? @constant type parameter))
+
+(member_expression . "." (identifier) @constant)
+
+(enum_declaration "{" (identifier) @constant)
+
+; Macros
+
+((call_expression function: (identifier) @function.macro)
+ (#lua-match? @function.macro "^_*[A-Z][A-Z0-9_]*$"))
+
+; Attributes
+
+(attribute (identifier) @attribute "="?)
+
+; Labels
+
+(label_statement (identifier) @label ":")
+
+; Literals
+
+(number) @number
+
+(float) @float
+
+(string) @string
+
+(character) @character
+
+(escape_sequence) @string.escape
+
+(boolean) @boolean
+
+[
+ (uninitialized)
+ (nil)
+] @constant.builtin
+
+((identifier) @variable.builtin
+ (#any-of? @variable.builtin "context" "self"))
+
+; Operators
+
+[
+ ":="
+ "="
+ "+"
+ "-"
+ "*"
+ "/"
+ "%"
+ "%%"
+ ">"
+ ">="
+ "<"
+ "<="
+ "=="
+ "!="
+ "~="
+ "|"
+ "~"
+ "&"
+ "&~"
+ "<<"
+ ">>"
+ "||"
+ "&&"
+ "!"
+ "^"
+ ".."
+ "+="
+ "-="
+ "*="
+ "/="
+ "%="
+ "&="
+ "|="
+ "^="
+ "<<="
+ ">>="
+ "||="
+ "&&="
+ "&~="
+ "..="
+ "..<"
+ "?"
+] @operator
+
+[
+ "or_else"
+ "in"
+ "not_in"
+] @keyword.operator
+
+; Punctuation
+
+[ "{" "}" ] @punctuation.bracket
+
+[ "(" ")" ] @punctuation.bracket
+
+[ "[" "]" ] @punctuation.bracket
+
+[
+ "::"
+ "->"
+ "."
+ ","
+ ":"
+ (separator)
+] @punctuation.delimiter
+
+
+[
+ "@"
+ "$"
+] @punctuation.special
+
+; Comments
+
+[
+ (comment)
+ (block_comment)
+] @comment @spell
+
+; Errors
+
+(ERROR) @error
diff --git a/queries/odin/indents.scm b/queries/odin/indents.scm
new file mode 100644
index 000000000..11dab0544
--- /dev/null
+++ b/queries/odin/indents.scm
@@ -0,0 +1,27 @@
+[
+ (block)
+ (procedure_declaration)
+ (overloaded_procedure_declaration)
+ (enum_declaration)
+ (union_declaration)
+ (if_statement)
+ (else_if_clause)
+ (else_clause)
+ (when_statement)
+ (else_when_clause)
+ (for_statement)
+ (switch_case)
+] @indent.begin
+
+[
+ "}"
+ ")"
+ "]"
+] @indent.branch @indent.end
+
+[
+ (comment)
+ (block_comment)
+ (string)
+ (ERROR)
+] @indent.auto
diff --git a/queries/odin/injections.scm b/queries/odin/injections.scm
new file mode 100644
index 000000000..4bb7d675d
--- /dev/null
+++ b/queries/odin/injections.scm
@@ -0,0 +1 @@
+(comment) @comment
diff --git a/queries/odin/locals.scm b/queries/odin/locals.scm
new file mode 100644
index 000000000..eb28ab952
--- /dev/null
+++ b/queries/odin/locals.scm
@@ -0,0 +1,39 @@
+; Scopes
+
+[
+ (block)
+ (declaration)
+ (statement)
+] @scope
+
+; References
+
+(identifier) @reference
+
+; Definitions
+
+(package_declaration (identifier) @definition.namespace)
+
+(import_declaration alias: (identifier) @definition.namespace)
+
+(procedure_declaration (identifier) @definition.function)
+
+(struct_declaration (identifier) @definition.type "::")
+
+(enum_declaration (identifier) @definition.enum "::")
+
+(union_declaration (identifier) @definition.type "::")
+
+(variable_declaration (identifier) @definition.var ":=")
+
+(const_declaration (identifier) @definition.constant "::")
+
+(const_type_declaration (identifier) @definition.type ":")
+
+(parameter (identifier) @definition.parameter ":"?)
+
+(default_parameter (identifier) @definition.parameter ":=")
+
+(field (identifier) @definition.field ":")
+
+(label_statement (identifier) @definition ":")