aboutsummaryrefslogtreecommitdiffstats
path: root/queries/ocaml
diff options
context:
space:
mode:
authorPau Ruiz Safont <unduthegun@gmail.com>2020-09-11 10:47:30 +0100
committerThomas Vigouroux <tomvig38@gmail.com>2020-09-11 12:10:31 +0200
commit7be8e6ca5c5dfe8414641c9d33605db31418debc (patch)
treed42a2cac0146835b614bc30fc4d1301aed24d130 /queries/ocaml
parentfeat(queries): pull ocaml queries from upstream (diff)
downloadnvim-treesitter-7be8e6ca5c5dfe8414641c9d33605db31418debc.tar
nvim-treesitter-7be8e6ca5c5dfe8414641c9d33605db31418debc.tar.gz
nvim-treesitter-7be8e6ca5c5dfe8414641c9d33605db31418debc.tar.bz2
nvim-treesitter-7be8e6ca5c5dfe8414641c9d33605db31418debc.tar.lz
nvim-treesitter-7be8e6ca5c5dfe8414641c9d33605db31418debc.tar.xz
nvim-treesitter-7be8e6ca5c5dfe8414641c9d33605db31418debc.tar.zst
nvim-treesitter-7be8e6ca5c5dfe8414641c9d33605db31418debc.zip
maintenance(ocaml): adapt queries to nvim-treesitter
Diffstat (limited to 'queries/ocaml')
-rw-r--r--queries/ocaml/highlights.scm35
-rw-r--r--queries/ocaml/locals.scm26
-rw-r--r--queries/ocaml/tags.scm99
3 files changed, 33 insertions, 127 deletions
diff --git a/queries/ocaml/highlights.scm b/queries/ocaml/highlights.scm
index 8033c817c..013f00d7f 100644
--- a/queries/ocaml/highlights.scm
+++ b/queries/ocaml/highlights.scm
@@ -1,19 +1,19 @@
; Modules
;--------
-[(module_name) (module_type_name)] @constructor
+[(module_name) (module_type_name)] @structure
; Types
;------
(
(type_constructor) @type.builtin
- (#match? @type.builtin "^(int|char|bytes|string|float|bool|unit|exn|array|list|option|int32|int64|nativeint|format6|lazy_t)$")
+ (#contains? @type.builtin "int" "char" "bytes" "string" "float" "bool" "unit" "exn" "array" "list" "option" "int32" "int64" "nativeint" "format6" "lazy_t")
)
[(class_name) (class_type_name) (type_constructor)] @type
-[(constructor_name) (tag)] @tag
+[(constructor_name) (tag)] @constructor
; Functions
;----------
@@ -30,7 +30,7 @@
(external (value_pattern) @function)
-(method_name) @function.method
+(method_name) @method
; Variables
;----------
@@ -39,7 +39,7 @@
(let_binding pattern: (value_pattern) @variable)
-(value_pattern) @variable.parameter
+(value_pattern) @parameter
; Application
;------------
@@ -78,9 +78,9 @@
(quoted_string "{" @string "}" @string) @string
-(escape_sequence) @escape
+(escape_sequence) @string.escape
-(conversion_specification) @string.special
+(conversion_specification) @punctuation.special
; Operators
;----------
@@ -108,13 +108,20 @@
;---------
[
- "and" "as" "assert" "begin" "class" "constraint" "do" "done" "downto" "else"
- "end" "exception" "external" "for" "fun" "function" "functor" "if" "in"
- "include" "inherit" "initializer" "lazy" "let" "match" "method" "module"
- "mutable" "new" "nonrec" "object" "of" "open" "private" "rec" "sig" "struct"
- "then" "to" "try" "type" "val" "virtual" "when" "while" "with"
+ "and" "as" "assert" "begin" "class" "constraint"
+ "end" "external" "fun" "function" "functor" "in"
+ "inherit" "initializer" "lazy" "let" "match" "method" "module"
+ "mutable" "new" "nonrec" "object" "of" "private" "rec" "sig" "struct"
+ "type" "val" "virtual" "when" "with"
] @keyword
+["if" "then" "else"] @conditional
+
+["exception" "try"] @exception
+
+["include" "open"] @include
+
+["for" "to" "downto" "while" "do" "done"] @repeat
; Punctuation
;------------
@@ -140,9 +147,11 @@
; Attributes
;-----------
-(attribute_id) @attribute
+(attribute_id) @property
; Comments
;---------
[(comment) (line_number_directive) (directive) (shebang)] @comment
+
+(ERROR) @error
diff --git a/queries/ocaml/locals.scm b/queries/ocaml/locals.scm
index 9ddaf4871..ec5ab928e 100644
--- a/queries/ocaml/locals.scm
+++ b/queries/ocaml/locals.scm
@@ -1,26 +1,22 @@
; Scopes
;-------
-(let_binding) @local.scope
-
-(class_binding) @local.scope
-
-(class_function) @local.scope
-
-(method_definition) @local.scope
-
-(fun_expression) @local.scope
-
-(match_case) @local.scope
-
-(for_expression) @local.scope
+[
+ (let_binding)
+ (class_binding)
+ (class_function)
+ (method_definition)
+ (fun_expression)
+ (match_case)
+ (for_expression)
+] @scope
; Definitions
;------------
-(value_pattern) @local.definition
+(value_pattern) @definition
; References
;------------
-(value_name) @local.reference
+(value_name) @reference
diff --git a/queries/ocaml/tags.scm b/queries/ocaml/tags.scm
deleted file mode 100644
index e572315ca..000000000
--- a/queries/ocaml/tags.scm
+++ /dev/null
@@ -1,99 +0,0 @@
-; Modules
-;--------
-
-(
- (comment)? @doc .
- (module_definition (module_binding (module_name) @name) @definition.module)
- (#strip! @doc "^\\(\\*\\*?\\s*|\\s\\*\\)$")
-)
-
-(module_path (module_name) @name) @reference.module
-
-; Modules types
-;--------------
-
-(
- (comment)? @doc .
- (module_type_definition (module_type_name) @name) @definition.interface
- (#strip! @doc "^\\(\\*\\*?\\s*|\\s\\*\\)$")
-)
-
-(module_type_path (module_type_name) @name) @reference.implementation
-
-; Functions
-;----------
-
-(
- (comment)? @doc .
- (value_definition
- [
- (let_binding
- pattern: (value_pattern) @name
- (parameter))
- (let_binding
- pattern: (value_pattern) @name
- body: [(fun_expression) (function_expression)])
- ] @definition.function
- )
- (#strip! @doc "^\\(\\*\\*?\\s*|\\s\\*\\)$")
-)
-
-(
- (comment)? @doc .
- (external (value_pattern) @name) @definition.function
- (#strip! @doc "^\\(\\*\\*?\\s*|\\s\\*\\)$")
-)
-
-(application_expression
- function: (value_path (value_name) @name)) @reference.call
-
-(infix_expression
- left: (value_path (value_name) @name)
- (infix_operator) @reference.call
- (#eq? @reference.call "@@"))
-
-(infix_expression
- (infix_operator) @reference.call
- right: (value_path (value_name) @name)
- (#eq? @reference.call "|>"))
-
-; Operator
-;---------
-
-(
- (comment)? @doc .
- (value_definition
- (let_binding
- pattern: (parenthesized_operator (_) @name)) @definition.function)
- (#strip! @doc "^\\(\\*\\*?\\s*|\\s\\*\\)$")
-)
-
-[(prefix_operator) (infix_operator) (indexing_operator) (let_operator) (and_operator) (match_operator)] @name @reference.call
-
-; Classes
-;--------
-
-(
- (comment)? @doc .
- [
- (class_definition (class_binding (class_name) @name) @definition.class)
- (class_type_definition (class_type_binding (class_type_name) @name) @definition.class)
- ]
- (#strip! @doc "^\\(\\*\\*?\\s*|\\s\\*\\)$")
-)
-
-[
- (class_path (class_name) @name)
- (class_type_path (class_type_name) @name)
-] @reference.class
-
-; Methods
-;--------
-
-(
- (comment)? @doc .
- (method_definition (method_name) @name) @definition.method
- (#strip! @doc "^\\(\\*\\*?\\s*|\\s\\*\\)$")
-)
-
-(method_invocation (method_name) @name) @reference.call