maintenance(ocaml): adapt queries to nvim-treesitter

This commit is contained in:
Pau Ruiz Safont 2020-09-11 10:47:30 +01:00 committed by Thomas Vigouroux
parent ddc200768e
commit 7be8e6ca5c
3 changed files with 33 additions and 127 deletions

View file

@ -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

View file

@ -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

View file

@ -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