diff --git a/runtime/queries/bibtex/tags.scm b/runtime/queries/bibtex/tags.scm deleted file mode 100644 index e69de29bb..000000000 diff --git a/runtime/queries/c-sharp/tags.scm b/runtime/queries/c-sharp/tags.scm index ffb2dd239..5a64c2d00 100644 --- a/runtime/queries/c-sharp/tags.scm +++ b/runtime/queries/c-sharp/tags.scm @@ -19,5 +19,3 @@ (invocation_expression function: (member_access_expression name: (identifier) @name)) @reference.send (namespace_declaration name: (identifier) @name) @definition.module - -(namespace_declaration name: (identifier) @name) @module diff --git a/runtime/queries/c/tags.scm b/runtime/queries/c/tags.scm new file mode 100644 index 000000000..f39212711 --- /dev/null +++ b/runtime/queries/c/tags.scm @@ -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) diff --git a/runtime/queries/cpp/tags.scm b/runtime/queries/cpp/tags.scm new file mode 100644 index 000000000..3e01de330 --- /dev/null +++ b/runtime/queries/cpp/tags.scm @@ -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)) diff --git a/runtime/queries/elixir/tags.scm b/runtime/queries/elixir/tags.scm new file mode 100644 index 000000000..582f11602 --- /dev/null +++ b/runtime/queries/elixir/tags.scm @@ -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 diff --git a/runtime/queries/erlang/tags.scm b/runtime/queries/erlang/tags.scm new file mode 100644 index 000000000..0aa0e33c2 --- /dev/null +++ b/runtime/queries/erlang/tags.scm @@ -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) diff --git a/runtime/queries/gdscript/tags.scm b/runtime/queries/gdscript/tags.scm index 05796fdf2..d2f4ffd9b 100644 --- a/runtime/queries/gdscript/tags.scm +++ b/runtime/queries/gdscript/tags.scm @@ -2,4 +2,4 @@ (function_definition (name) @name) @definition.function -(call (name) @name) @reference.call \ No newline at end of file +(call (identifier) @name) @reference.call diff --git a/runtime/queries/go/tags.scm b/runtime/queries/go/tags.scm index d87008ab2..b7049c7c9 100644 --- a/runtime/queries/go/tags.scm +++ b/runtime/queries/go/tags.scm @@ -4,7 +4,7 @@ (function_declaration name: (identifier) @name) @definition.function (#strip! @doc "^//\\s*") - (#set-adjacent! @doc @definition.function) + (#select-adjacent! @doc @definition.function) ) ( @@ -13,7 +13,7 @@ (method_declaration name: (field_identifier) @name) @definition.method (#strip! @doc "^//\\s*") - (#set-adjacent! @doc @definition.method) + (#select-adjacent! @doc @definition.method) ) (call_expression diff --git a/runtime/queries/markdown/tags.scm b/runtime/queries/markdown/tags.scm new file mode 100644 index 000000000..38a69718e --- /dev/null +++ b/runtime/queries/markdown/tags.scm @@ -0,0 +1,2 @@ +; TODO: have symbol types for markup? +(atx_heading) @definition.class diff --git a/runtime/queries/rust/tags.scm b/runtime/queries/rust/tags.scm new file mode 100644 index 000000000..c5700ea62 --- /dev/null +++ b/runtime/queries/rust/tags.scm @@ -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) diff --git a/runtime/queries/typst/tags.scm b/runtime/queries/typst/tags.scm new file mode 100644 index 000000000..e6f22998e --- /dev/null +++ b/runtime/queries/typst/tags.scm @@ -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)