aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorap296002023-04-27 14:32:21 +0000
committerGitHub2023-04-27 14:32:21 +0000
commit9cdc6b2e8a0193881297e15641cd801384cd8865 (patch)
tree2671ec29437a24f3a9f62ffcdf28f1b4d2fe7ecc
parent2836ea2ac40bd54ec1b00ffcd5927cdb4b7724d3 (diff)
Change Odin grammar to `ap29600/tree-sitter-odin` (#6766)
* 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. * update queries * docgen * fix queries * Update runtime/queries/odin/highlights.scm Co-authored-by: Michael Davis <mcarsondavis@gmail.com> * remove `ERROR` query for `odin` * track the latest rev in `ap29600/tree-sitter-odin` * runtime/queries/odin/highlights.scm: update rune highlight class Co-authored-by: Michael Davis <mcarsondavis@gmail.com> --------- Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
-rw-r--r--book/src/generated/lang-support.md2
-rw-r--r--languages.toml2
-rw-r--r--runtime/queries/odin/highlights.scm151
-rw-r--r--runtime/queries/odin/indents.scm16
4 files changed, 36 insertions, 135 deletions
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index 900664d2..b08bf155 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 | ✓ | | | |
diff --git a/languages.toml b/languages.toml
index 00df3239..14da46c1 100644
--- a/languages.toml
+++ b/languages.toml
@@ -1675,7 +1675,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 = "b219207e49ffca2952529d33e94ed63b1b75c4f1" }
[[language]]
name = "meson"
diff --git a/runtime/queries/odin/highlights.scm b/runtime/queries/odin/highlights.scm
index 1d801ff1..d474bf3a 100644
--- a/runtime/queries/odin/highlights.scm
+++ b/runtime/queries/odin/highlights.scm
@@ -1,141 +1,26 @@
-; Function calls
+(keyword) @keyword
+(operator) @operator
-(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) @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"
-
- "break"
- "case"
- "continue"
- "defer"
- "else"
- "using"
- "when"
- "where"
- "fallthrough"
- "for"
- "proc"
- "if"
- "import"
- "map"
- "package"
- "return"
- "struct"
- "union"
- "enum"
- "switch"
- "dynamic"
-] @keyword
-
-; ; Literals
+(int_literal) @constant.numeric.integer
+(float_literal) @constant.numeric.float
+(rune_literal) @constant.character
+(bool_literal) @constant.builtin.boolean
+(nil) @constant.builtin
-[
- (interpreted_string_literal)
- (raw_string_literal)
- (rune_literal)
-] @string
+(type_identifier) @type
+(package_identifier) @namespace
+(label_identifier) @label
+(interpreted_string_literal) @string
+(raw_string_literal) @string
(escape_sequence) @constant.character.escape
-(int_literal) @constant.numeric.integer
-(float_literal) @constant.numeric.float
-(imaginary_literal) @constant.numeric
+(comment) @comment
+(const_identifier) @constant
-[
- (true)
- (false)
-] @constant.builtin.boolean
-[
- (nil)
- (undefined)
-] @constant.builtin
+(compiler_directive) @keyword.directive
+(calling_convention) @string.special.symbol
-(comment) @comment.line
+(identifier) @variable
+(pragma_identifier) @keyword.directive
diff --git a/runtime/queries/odin/indents.scm b/runtime/queries/odin/indents.scm
new file mode 100644
index 00000000..a3b90a38
--- /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
+
+[
+ ")"
+ "}"
+] @outdent
+