diff options
| author | Christian Clason <c.clason@uni-graz.at> | 2023-06-12 09:54:30 -0600 |
|---|---|---|
| committer | Christian Clason <c.clason@uni-graz.at> | 2025-05-12 18:43:40 +0200 |
| commit | 692b051b09935653befdb8f7ba8afdb640adf17b (patch) | |
| tree | 167162b6b129ae04f68c5735078521a72917c742 /runtime/queries/odin | |
| parent | feat(c-family): inherit injections (diff) | |
| download | nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.gz nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.bz2 nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.lz nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.xz nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.zst nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.zip | |
feat!: drop modules, general refactor and cleanup
Diffstat (limited to 'runtime/queries/odin')
| -rw-r--r-- | runtime/queries/odin/folds.scm | 7 | ||||
| -rw-r--r-- | runtime/queries/odin/highlights.scm | 350 | ||||
| -rw-r--r-- | runtime/queries/odin/indents.scm | 46 | ||||
| -rw-r--r-- | runtime/queries/odin/injections.scm | 2 | ||||
| -rw-r--r-- | runtime/queries/odin/locals.scm | 63 |
5 files changed, 468 insertions, 0 deletions
diff --git a/runtime/queries/odin/folds.scm b/runtime/queries/odin/folds.scm new file mode 100644 index 000000000..5367cb5f2 --- /dev/null +++ b/runtime/queries/odin/folds.scm @@ -0,0 +1,7 @@ +[ + (declaration) + (statement) + (else_when_clause) + (else_if_clause) + (else_clause) +] @fold diff --git a/runtime/queries/odin/highlights.scm b/runtime/queries/odin/highlights.scm new file mode 100644 index 000000000..b7e2176a8 --- /dev/null +++ b/runtime/queries/odin/highlights.scm @@ -0,0 +1,350 @@ +; Preprocs +[ + (calling_convention) + (tag) +] @keyword.directive + +; Includes +[ + "import" + "package" +] @keyword.import + +; Keywords +[ + "foreign" + "using" + "defer" + "cast" + "transmute" + "auto_cast" + "map" + "bit_set" + "matrix" +] @keyword + +[ + "struct" + "enum" + "union" + "bit_field" +] @keyword.type + +"proc" @keyword.function + +[ + "return" + "or_return" +] @keyword.return + +[ + "distinct" + "dynamic" +] @keyword.modifier + +; Conditionals +[ + "if" + "else" + "when" + "switch" + "case" + "where" + "break" + "or_break" + "or_continue" + (fallthrough_statement) +] @keyword.conditional + +((ternary_expression + [ + "?" + ":" + "if" + "else" + "when" + ] @keyword.conditional.ternary) + (#set! priority 105)) + +; Repeats +[ + "for" + "do" + "continue" +] @keyword.repeat + +; Variables +(identifier) @variable + +; Namespaces +(package_declaration + (identifier) @module) + +(import_declaration + alias: (identifier) @module) + +(foreign_block + (identifier) @module) + +(using_statement + (identifier) @module) + +; Parameters +(parameter + (identifier) @variable.parameter + ":" + "="? + (identifier)? @constant) + +(default_parameter + (identifier) @variable.parameter + ":=") + +(named_type + (identifier) @variable.parameter) + +(call_expression + argument: (identifier) @variable.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 + "::") + +(bit_field_declaration + (identifier) @type + "::") + +(const_declaration + (identifier) @type + "::" + [ + (array_type) + (distinct_type) + (bit_set_type) + (pointer_type) + ]) + +(struct + . + (identifier) @type) + +(field_type + . + (identifier) @module + "." + (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 call_expression)) + +; Fields +(member_expression + "." + (identifier) @variable.member) + +(struct_type + "{" + (identifier) @variable.member) + +(struct_field + (identifier) @variable.member + "="?) + +(field + (identifier) @variable.member) + +; 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) @number.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 + +[ + "::" + "->" + "." + "," + ":" + ";" +] @punctuation.delimiter + +[ + "@" + "$" +] @punctuation.special + +; Comments +[ + (comment) + (block_comment) +] @comment @spell diff --git a/runtime/queries/odin/indents.scm b/runtime/queries/odin/indents.scm new file mode 100644 index 000000000..9c8632978 --- /dev/null +++ b/runtime/queries/odin/indents.scm @@ -0,0 +1,46 @@ +[ + (block) + (enum_declaration) + (union_declaration) + (bit_field_declaration) + (struct_declaration) + (struct) + (parameters) + (tuple_type) + (call_expression) + (switch_case) +] @indent.begin + +; hello( +((identifier) + . + (ERROR + "(" @indent.begin)) + +[ + ")" + "]" +] @indent.branch @indent.end + +; Have to do all closing brackets separately because the one for switch statements shouldn't end. +(block + "}" @indent.branch @indent.end) + +(enum_declaration + "}" @indent.branch @indent.end) + +(union_declaration + "}" @indent.branch @indent.end) + +(struct_declaration + "}" @indent.branch @indent.end) + +(struct + "}" @indent.branch @indent.end) + +[ + (comment) + (block_comment) + (string) + (ERROR) +] @indent.auto diff --git a/runtime/queries/odin/injections.scm b/runtime/queries/odin/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/runtime/queries/odin/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/odin/locals.scm b/runtime/queries/odin/locals.scm new file mode 100644 index 000000000..3e794b2f6 --- /dev/null +++ b/runtime/queries/odin/locals.scm @@ -0,0 +1,63 @@ +; Scopes +[ + (block) + (declaration) + (statement) +] @local.scope + +; References +(identifier) @local.reference + +; Definitions +(package_declaration + (identifier) @local.definition.namespace) + +(import_declaration + alias: (identifier) @local.definition.namespace) + +(procedure_declaration + (identifier) @local.definition.function) + +(struct_declaration + (identifier) @local.definition.type + "::") + +(enum_declaration + (identifier) @local.definition.enum + "::") + +(union_declaration + (identifier) @local.definition.type + "::") + +(bit_field_declaration + (identifier) @local.definition.type + "::") + +(variable_declaration + (identifier) @local.definition.var + ":=") + +(const_declaration + (identifier) @local.definition.constant + "::") + +(const_type_declaration + (identifier) @local.definition.type + ":") + +(parameter + (identifier) @local.definition.parameter + ":"?) + +(default_parameter + (identifier) @local.definition.parameter + ":=") + +(field + (identifier) @local.definition.field + ":") + +(label_statement + (identifier) @local.definition + ":") |
