From cd2e38aa9e3ff02561e3f52aabe36f24d243d1c4 Mon Sep 17 00:00:00 2001 From: ap29600 <66381278+ap29600@users.noreply.github.com> Date: Sat, 15 Apr 2023 14:22:35 +0200 Subject: [PATCH 1/8] Change Odin grammar to `ap29600/tree-sitter-odin` The previously adopted grammar, `MineBill/tree-sitter-odin`, is unmaintained and mentions my repository as an alternative source. --- languages.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages.toml b/languages.toml index 8a0aa66120cb..450bd5d5f717 100644 --- a/languages.toml +++ b/languages.toml @@ -1674,7 +1674,7 @@ indent = { tab-width = 4, unit = "\t" } [[grammar]] name = "odin" -source = { git = "https://github.com/MineBill/tree-sitter-odin", rev = "da885f4a387f169b9b69fe0968259ee257a8f69a" } +source = { git = "https://github.com/ap29600/tree-sitter-odin", rev = "62ffeb15eca4b8981115a1d7df499bcfa3887d43" } [[language]] name = "meson" From 8932ff1a9f059c0e066a83729705a266b2540da4 Mon Sep 17 00:00:00 2001 From: Andrea Piseri Date: Sat, 15 Apr 2023 15:49:26 +0200 Subject: [PATCH 2/8] update queries --- runtime/queries/odin/highlights.scm | 152 ++++------------------------ runtime/queries/odin/indents.scm | 16 +++ 2 files changed, 36 insertions(+), 132 deletions(-) create mode 100644 runtime/queries/odin/indents.scm diff --git a/runtime/queries/odin/highlights.scm b/runtime/queries/odin/highlights.scm index 1d801ff1b823..80fd90dec765 100644 --- a/runtime/queries/odin/highlights.scm +++ b/runtime/queries/odin/highlights.scm @@ -1,141 +1,29 @@ -; Function calls +(keyword) @keyword +(operator) @operator -(call_expression - function: (identifier) @function) +(int_literal) @number +(float_literal) @number +(rune_literal) @number +(bool_literal) @boolean +(nil) @constant.builtin -(call_expression - function: (selector_expression - field: (field_identifier) @function)) +(ERROR) @error -; ; Function definitions +(type_identifier) @type +(package_identifier) @namespace +(label_identifier) @label -(function_declaration - name: (identifier) @function) +(interpreted_string_literal) @string +(raw_string_literal) @string +(escape_sequence) @string.escape -(proc_group - (identifier) @function) +(comment) @comment +(const_identifier) @constant -; ; Identifiers -(type_identifier) @type -(field_identifier) @variable.other.member -(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" +(compiler_directive) @attribute +(calling_convention) @attribute - "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) @constant.character.escape - -(int_literal) @constant.numeric.integer -(float_literal) @constant.numeric.float -(imaginary_literal) @constant.numeric - -[ - (true) - (false) -] @constant.builtin.boolean - -[ - (nil) - (undefined) -] @constant.builtin - -(comment) @comment.line +(identifier) @variable +(pragma_identifier) @attribute diff --git a/runtime/queries/odin/indents.scm b/runtime/queries/odin/indents.scm new file mode 100644 index 000000000000..c304876fbe29 --- /dev/null +++ b/runtime/queries/odin/indents.scm @@ -0,0 +1,16 @@ +[ + (foreign_block) + (block) + (compound_literal) + (proc_call) + (assignment_statement) + (const_declaration) + (var_declaration) + (switch_statement) +] @indent + +[ + ")" + "}" +] @indent_end @branch + From 89733e18a8f966dfabb760e2002bc524e1c8f432 Mon Sep 17 00:00:00 2001 From: Andrea Piseri Date: Sat, 15 Apr 2023 17:49:18 +0200 Subject: [PATCH 3/8] docgen --- book/src/generated/lang-support.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 331d212f5742..69e56e358dcf 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -98,7 +98,7 @@ | nu | ✓ | | | | | ocaml | ✓ | | ✓ | `ocamllsp` | | ocaml-interface | ✓ | | | `ocamllsp` | -| odin | ✓ | | | `ols` | +| odin | ✓ | | ✓ | `ols` | | opencl | ✓ | ✓ | ✓ | `clangd` | | openscad | ✓ | | | `openscad-lsp` | | org | ✓ | | | | From 44c16d0a0bd49a3f36a122fa069d9b58eade5734 Mon Sep 17 00:00:00 2001 From: Andrea Piseri Date: Mon, 17 Apr 2023 13:13:59 +0200 Subject: [PATCH 4/8] fix queries --- runtime/queries/odin/highlights.scm | 18 +++++++++--------- runtime/queries/odin/indents.scm | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/runtime/queries/odin/highlights.scm b/runtime/queries/odin/highlights.scm index 80fd90dec765..e1a3d9f97b0d 100644 --- a/runtime/queries/odin/highlights.scm +++ b/runtime/queries/odin/highlights.scm @@ -1,14 +1,14 @@ (keyword) @keyword (operator) @operator -(int_literal) @number -(float_literal) @number -(rune_literal) @number -(bool_literal) @boolean +(int_literal) @constant.numeric +(float_literal) @constant.numeric +(rune_literal) @string.character +(bool_literal) @constant.builtin.boolean (nil) @constant.builtin -(ERROR) @error +(ERROR) @special (type_identifier) @type (package_identifier) @namespace @@ -16,14 +16,14 @@ (interpreted_string_literal) @string (raw_string_literal) @string -(escape_sequence) @string.escape +(escape_sequence) @constant.character.escape (comment) @comment (const_identifier) @constant -(compiler_directive) @attribute -(calling_convention) @attribute +(compiler_directive) @keyword.directive +(calling_convention) @string.special.symbol (identifier) @variable -(pragma_identifier) @attribute +(pragma_identifier) @keyword.directive diff --git a/runtime/queries/odin/indents.scm b/runtime/queries/odin/indents.scm index c304876fbe29..a3b90a38df3f 100644 --- a/runtime/queries/odin/indents.scm +++ b/runtime/queries/odin/indents.scm @@ -12,5 +12,5 @@ [ ")" "}" -] @indent_end @branch +] @outdent From 64f7f849e8ba2d3db0f863dc23e76f023897ea3c Mon Sep 17 00:00:00 2001 From: ap29600 <66381278+ap29600@users.noreply.github.com> Date: Sun, 23 Apr 2023 15:58:04 +0200 Subject: [PATCH 5/8] Update runtime/queries/odin/highlights.scm Co-authored-by: Michael Davis --- runtime/queries/odin/highlights.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/queries/odin/highlights.scm b/runtime/queries/odin/highlights.scm index e1a3d9f97b0d..4f2d795a4538 100644 --- a/runtime/queries/odin/highlights.scm +++ b/runtime/queries/odin/highlights.scm @@ -1,8 +1,8 @@ (keyword) @keyword (operator) @operator -(int_literal) @constant.numeric -(float_literal) @constant.numeric +(int_literal) @constant.numeric.integer +(float_literal) @constant.numeric.float (rune_literal) @string.character (bool_literal) @constant.builtin.boolean (nil) @constant.builtin From fe3ff26048698f033026c1b3bbc0838dc565134c Mon Sep 17 00:00:00 2001 From: ap29600 <66381278+ap29600@users.noreply.github.com> Date: Sun, 23 Apr 2023 16:04:42 +0200 Subject: [PATCH 6/8] remove `ERROR` query for `odin` --- runtime/queries/odin/highlights.scm | 3 --- 1 file changed, 3 deletions(-) diff --git a/runtime/queries/odin/highlights.scm b/runtime/queries/odin/highlights.scm index 4f2d795a4538..36358709dd25 100644 --- a/runtime/queries/odin/highlights.scm +++ b/runtime/queries/odin/highlights.scm @@ -7,9 +7,6 @@ (bool_literal) @constant.builtin.boolean (nil) @constant.builtin - -(ERROR) @special - (type_identifier) @type (package_identifier) @namespace (label_identifier) @label From 59096a94455fd5ceef860d80f433de58cfde120b Mon Sep 17 00:00:00 2001 From: ap29600 <66381278+ap29600@users.noreply.github.com> Date: Sun, 23 Apr 2023 16:09:11 +0200 Subject: [PATCH 7/8] track the latest rev in `ap29600/tree-sitter-odin` --- languages.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages.toml b/languages.toml index 450bd5d5f717..1f5c38b9b0e4 100644 --- a/languages.toml +++ b/languages.toml @@ -1674,7 +1674,7 @@ indent = { tab-width = 4, unit = "\t" } [[grammar]] name = "odin" -source = { git = "https://github.com/ap29600/tree-sitter-odin", rev = "62ffeb15eca4b8981115a1d7df499bcfa3887d43" } +source = { git = "https://github.com/ap29600/tree-sitter-odin", rev = "b219207e49ffca2952529d33e94ed63b1b75c4f1" } [[language]] name = "meson" From 92e7c042843838250c8d105387785820a71a857d Mon Sep 17 00:00:00 2001 From: ap29600 <66381278+ap29600@users.noreply.github.com> Date: Thu, 27 Apr 2023 10:03:28 +0200 Subject: [PATCH 8/8] runtime/queries/odin/highlights.scm: update rune highlight class Co-authored-by: Michael Davis --- runtime/queries/odin/highlights.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/queries/odin/highlights.scm b/runtime/queries/odin/highlights.scm index 36358709dd25..d474bf3a221f 100644 --- a/runtime/queries/odin/highlights.scm +++ b/runtime/queries/odin/highlights.scm @@ -3,7 +3,7 @@ (int_literal) @constant.numeric.integer (float_literal) @constant.numeric.float -(rune_literal) @string.character +(rune_literal) @constant.character (bool_literal) @constant.builtin.boolean (nil) @constant.builtin