mirror of https://github.com/helix-editor/helix
Add initial tags.scm queries
Co-authored-by: cgahr <26804763+cgahr@users.noreply.github.com> Co-authored-by: eh <correia.eh@gmail.com>pull/12275/head
parent
2d5826d194
commit
63eb1b870c
|
@ -19,5 +19,3 @@
|
||||||
(invocation_expression function: (member_access_expression name: (identifier) @name)) @reference.send
|
(invocation_expression function: (member_access_expression name: (identifier) @name)) @reference.send
|
||||||
|
|
||||||
(namespace_declaration name: (identifier) @name) @definition.module
|
(namespace_declaration name: (identifier) @name) @definition.module
|
||||||
|
|
||||||
(namespace_declaration name: (identifier) @name) @module
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
(function_declarator
|
||||||
|
declarator: [(identifier) (field_identifier)] @definition.function)
|
||||||
|
|
||||||
|
(preproc_function_def name: (identifier) @definition.function)
|
||||||
|
|
||||||
|
(type_definition
|
||||||
|
declarator: (type_identifier) @definition.type)
|
||||||
|
|
||||||
|
(preproc_def name: (identifier) @definition.constant)
|
|
@ -0,0 +1,12 @@
|
||||||
|
; inherits: c
|
||||||
|
|
||||||
|
(function_declarator
|
||||||
|
declarator: (qualified_identifier name: (identifier) @definition.function))
|
||||||
|
|
||||||
|
(struct_specifier
|
||||||
|
name: (type_identifier) @definition.struct
|
||||||
|
body: (field_declaration_list))
|
||||||
|
|
||||||
|
(class_specifier
|
||||||
|
name: (type_identifier) @definition.class
|
||||||
|
body: (field_declaration_list))
|
|
@ -0,0 +1,54 @@
|
||||||
|
; Definitions
|
||||||
|
|
||||||
|
; * modules and protocols
|
||||||
|
(call
|
||||||
|
target: (identifier) @ignore
|
||||||
|
(arguments (alias) @name)
|
||||||
|
(#any-of? @ignore "defmodule" "defprotocol")) @definition.module
|
||||||
|
|
||||||
|
; * functions/macros
|
||||||
|
(call
|
||||||
|
target: (identifier) @ignore
|
||||||
|
(arguments
|
||||||
|
[
|
||||||
|
; zero-arity functions with no parentheses
|
||||||
|
(identifier) @name
|
||||||
|
; regular function clause
|
||||||
|
(call target: (identifier) @name)
|
||||||
|
; function clause with a guard clause
|
||||||
|
(binary_operator
|
||||||
|
left: (call target: (identifier) @name)
|
||||||
|
operator: "when")
|
||||||
|
])
|
||||||
|
(#any-of? @ignore "def" "defp" "defdelegate" "defguard" "defguardp" "defmacro" "defmacrop" "defn" "defnp")) @definition.function
|
||||||
|
|
||||||
|
; References
|
||||||
|
|
||||||
|
; ignore calls to kernel/special-forms keywords
|
||||||
|
(call
|
||||||
|
target: (identifier) @ignore
|
||||||
|
(#any-of? @ignore "def" "defp" "defdelegate" "defguard" "defguardp" "defmacro" "defmacrop" "defn" "defnp" "defmodule" "defprotocol" "defimpl" "defstruct" "defexception" "defoverridable" "alias" "case" "cond" "else" "for" "if" "import" "quote" "raise" "receive" "require" "reraise" "super" "throw" "try" "unless" "unquote" "unquote_splicing" "use" "with"))
|
||||||
|
|
||||||
|
; ignore module attributes
|
||||||
|
(unary_operator
|
||||||
|
operator: "@"
|
||||||
|
operand: (call
|
||||||
|
target: (identifier) @ignore))
|
||||||
|
|
||||||
|
; * function call
|
||||||
|
(call
|
||||||
|
target: [
|
||||||
|
; local
|
||||||
|
(identifier) @name
|
||||||
|
; remote
|
||||||
|
(dot
|
||||||
|
right: (identifier) @name)
|
||||||
|
]) @reference.call
|
||||||
|
|
||||||
|
; * pipe into function call
|
||||||
|
(binary_operator
|
||||||
|
operator: "|>"
|
||||||
|
right: (identifier) @name) @reference.call
|
||||||
|
|
||||||
|
; * modules
|
||||||
|
(alias) @name @reference.module
|
|
@ -0,0 +1,45 @@
|
||||||
|
; Modules
|
||||||
|
(attribute
|
||||||
|
name: (atom) @_attr
|
||||||
|
(arguments (atom) @definition.module)
|
||||||
|
(#eq? @_attr "module"))
|
||||||
|
|
||||||
|
; Constants
|
||||||
|
((attribute
|
||||||
|
name: (atom) @_attr
|
||||||
|
(arguments
|
||||||
|
.
|
||||||
|
[
|
||||||
|
(atom) @definition.constant
|
||||||
|
(call function: [(variable) (atom)] @definition.macro)
|
||||||
|
]))
|
||||||
|
(#eq? @_attr "define"))
|
||||||
|
|
||||||
|
; Record definitions
|
||||||
|
((attribute
|
||||||
|
name: (atom) @_attr
|
||||||
|
(arguments
|
||||||
|
.
|
||||||
|
(atom) @definition.struct))
|
||||||
|
(#eq? @_attr "record"))
|
||||||
|
|
||||||
|
; Function specs
|
||||||
|
((attribute
|
||||||
|
name: (atom) @_attr
|
||||||
|
(stab_clause name: (atom) @definition.interface))
|
||||||
|
(#eq? @_attr "spec"))
|
||||||
|
|
||||||
|
; Types
|
||||||
|
((attribute
|
||||||
|
name: (atom) @_attr
|
||||||
|
(arguments
|
||||||
|
(binary_operator
|
||||||
|
left: [
|
||||||
|
(atom) @definition.type
|
||||||
|
(call function: (atom) @definition.type)
|
||||||
|
]
|
||||||
|
operator: "::")))
|
||||||
|
(#any-of? @_attr "type" "opaque"))
|
||||||
|
|
||||||
|
; Functions
|
||||||
|
(function_clause name: (atom) @definition.function)
|
|
@ -2,4 +2,4 @@
|
||||||
|
|
||||||
(function_definition (name) @name) @definition.function
|
(function_definition (name) @name) @definition.function
|
||||||
|
|
||||||
(call (name) @name) @reference.call
|
(call (identifier) @name) @reference.call
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
(function_declaration
|
(function_declaration
|
||||||
name: (identifier) @name) @definition.function
|
name: (identifier) @name) @definition.function
|
||||||
(#strip! @doc "^//\\s*")
|
(#strip! @doc "^//\\s*")
|
||||||
(#set-adjacent! @doc @definition.function)
|
(#select-adjacent! @doc @definition.function)
|
||||||
)
|
)
|
||||||
|
|
||||||
(
|
(
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
(method_declaration
|
(method_declaration
|
||||||
name: (field_identifier) @name) @definition.method
|
name: (field_identifier) @name) @definition.method
|
||||||
(#strip! @doc "^//\\s*")
|
(#strip! @doc "^//\\s*")
|
||||||
(#set-adjacent! @doc @definition.method)
|
(#select-adjacent! @doc @definition.method)
|
||||||
)
|
)
|
||||||
|
|
||||||
(call_expression
|
(call_expression
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
; TODO: have symbol types for markup?
|
||||||
|
(atx_heading) @definition.class
|
|
@ -0,0 +1,26 @@
|
||||||
|
(struct_item
|
||||||
|
name: (type_identifier) @definition.struct)
|
||||||
|
|
||||||
|
(const_item
|
||||||
|
name: (identifier) @definition.constant)
|
||||||
|
|
||||||
|
(trait_item
|
||||||
|
name: (type_identifier) @definition.interface)
|
||||||
|
|
||||||
|
(function_item
|
||||||
|
name: (identifier) @definition.function)
|
||||||
|
|
||||||
|
(function_signature_item
|
||||||
|
name: (identifier) @definition.function)
|
||||||
|
|
||||||
|
(enum_item
|
||||||
|
name: (type_identifier) @definition.type)
|
||||||
|
|
||||||
|
(enum_variant
|
||||||
|
name: (identifier) @definition.struct)
|
||||||
|
|
||||||
|
(mod_item
|
||||||
|
name: (identifier) @definition.module)
|
||||||
|
|
||||||
|
(macro_definition
|
||||||
|
name: (identifier) @definition.macro)
|
|
@ -0,0 +1,6 @@
|
||||||
|
; should be a heading
|
||||||
|
(heading (text) @definition.class)
|
||||||
|
|
||||||
|
; should be a label/reference/tag
|
||||||
|
(heading (label) @definition.function)
|
||||||
|
(content (label) @definition.function)
|
Loading…
Reference in New Issue