Skip to content

Instantly share code, notes, and snippets.

@ntoxeg
Last active June 7, 2025 08:55
Show Gist options
  • Save ntoxeg/50bb3b7d7af560ebe4f5bfd51ed3f972 to your computer and use it in GitHub Desktop.
Save ntoxeg/50bb3b7d7af560ebe4f5bfd51ed3f972 to your computer and use it in GitHub Desktop.
tree-sitter tags file for Julia
; Modules
(
(module_definition
(identifier) @name) @definition.module
)
; Types (Structs, Abstract, Primitive)
(
(struct_definition
(type_head [
(identifier) @name ; Direct identifier: struct Foo ...
(parametrized_type_expression (identifier) @name .) ; Parametric: struct Foo{T} ...
(binary_expression ; Inheritance: struct Foo <: Bar ... or struct Foo{T} <: Bar{T} ...
[
(identifier) @name
(parametrized_type_expression (identifier) @name .)
]
(operator) ; Operator (e.g., <:) - could be alias too
(_) ; RHS (parent type) - we don't need to capture this
)
])
) @definition.structure
)
(
(abstract_definition
(type_head (identifier) @name)) @definition.abstract
)
(
(primitive_definition
(type_head (identifier) @name)) @definition.primitive
)
; Functions
(
(function_definition
(signature
(call_expression
(identifier) @name))) @definition.function
)
; Macro-wrapped function definition
(
(macrocall_expression
(macro_argument_list
(function_definition
(signature
[ ; Match either direct call or call inside where
(call_expression
(identifier) @name)
(where_expression
(call_expression
(identifier) @name) @ignore)
]
)
)
)
) @definition.function
)
; Short-form function definition
(
(assignment
(call_expression
(identifier) @name)
(operator)
(_expression)
) @definition.function
)
; Macros
(
(macro_definition
(signature
(call_expression
(identifier) @name))) @definition.macro
)
; Constants
(
(const_statement
(assignment
(identifier) @name
"="
(_)
)
) @definition.constant
)
; Struct fields
[
(struct_definition
(identifier) @name @definition.field
)
(struct_definition
(typed_expression (identifier) @name) @definition.field
)
]
@mauro3
Copy link

mauro3 commented Jun 7, 2025

I can try to get this going, i.e. the PR to tree sitter, if you want me to using this file. I'd make sure that you are mentioned in the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment