Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ tree-sitter-ruby = "0.23"
tree-sitter-go = "0.25"
tree-sitter-c-sharp = "0.23"
tree-sitter-zig = "1.1"
tree-sitter-elixir = "0.3"
fastembed = { version = "5.1", default-features = false, features = ["hf-hub-rustls-tls", "ort-download-binaries"] }
openssl = { version = "0.10" }
tempfile = "3.8"
Expand Down
1 change: 1 addition & 0 deletions ck-chunk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ tree-sitter-ruby = { workspace = true }
tree-sitter-go = { workspace = true }
tree-sitter-c-sharp = { workspace = true }
tree-sitter-zig = { workspace = true }
tree-sitter-elixir = { workspace = true }
tracing = { workspace = true }
hf-hub = "0.3"
tokenizers = { version = "0.22", default-features = false, features = ["onig", "progressbar"] }
136 changes: 136 additions & 0 deletions ck-chunk/queries/elixir/tags.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
; Elixir chunk definitions
; In Elixir's tree-sitter grammar, definitions like defmodule, def, defp
; are represented as function calls with specific target identifiers

; Module definition - defmodule ModuleName do ... end
(call
target: (identifier) @_target
(arguments
(alias) @name)
(#eq? @_target "defmodule")) @module

; Public function - def function_name(...) do ... end
(call
target: (identifier) @_target
(#eq? @_target "def")) @definition.function

; Private function - defp function_name(...) do ... end
(call
target: (identifier) @_target
(#eq? @_target "defp")) @definition.function

; Public macro - defmacro macro_name(...) do ... end
(call
target: (identifier) @_target
(#eq? @_target "defmacro")) @definition.function

; Private macro - defmacrop macro_name(...) do ... end
(call
target: (identifier) @_target
(#eq? @_target "defmacrop")) @definition.function

; Protocol definition - defprotocol ProtocolName do ... end
(call
target: (identifier) @_target
(#eq? @_target "defprotocol")) @module

; Protocol implementation - defimpl Protocol, for: Type do ... end
(call
target: (identifier) @_target
(#eq? @_target "defimpl")) @module

; Struct definition - defstruct [...] (inside a module)
(call
target: (identifier) @_target
(#eq? @_target "defstruct")) @definition.struct

; Exception definition - defexception [...] (inside a module)
(call
target: (identifier) @_target
(#eq? @_target "defexception")) @definition.struct

; Guard definitions
(call
target: (identifier) @_target
(#eq? @_target "defguard")) @definition.function

(call
target: (identifier) @_target
(#eq? @_target "defguardp")) @definition.function

; Delegate function - defdelegate function_name(args), to: Module
(call
target: (identifier) @_target
(#eq? @_target "defdelegate")) @definition.function

; Override callback - defoverridable [...]
(call
target: (identifier) @_target
(#eq? @_target "defoverridable")) @definition.text

; =============================================================================
; Module Attributes - @spec, @type, @callback, @behaviour
; =============================================================================
; Module attributes in Elixir are parsed as unary_operator with @ operator,
; containing a call node where the identifier is the attribute name.

; Type specification - @spec function_name(arg_types) :: return_type
(unary_operator
operator: "@"
operand: (call
target: (identifier) @_attr
(#eq? @_attr "spec"))) @definition.spec

; Type definitions - @type, @typep (private), @opaque
(unary_operator
operator: "@"
operand: (call
target: (identifier) @_attr
(#eq? @_attr "type"))) @definition.type

(unary_operator
operator: "@"
operand: (call
target: (identifier) @_attr
(#eq? @_attr "typep"))) @definition.type

(unary_operator
operator: "@"
operand: (call
target: (identifier) @_attr
(#eq? @_attr "opaque"))) @definition.type

; Callback definition - @callback function_name(arg_types) :: return_type
(unary_operator
operator: "@"
operand: (call
target: (identifier) @_attr
(#eq? @_attr "callback"))) @definition.callback

; Optional callback - @optional_callbacks [callback_name: arity, ...]
(unary_operator
operator: "@"
operand: (call
target: (identifier) @_attr
(#eq? @_attr "optional_callbacks"))) @definition.callback

; Macro callback - @macrocallback macro_name(arg_types) :: return_type
(unary_operator
operator: "@"
operand: (call
target: (identifier) @_attr
(#eq? @_attr "macrocallback"))) @definition.callback

; Behaviour declaration - @behaviour ModuleName
(unary_operator
operator: "@"
operand: (call
target: (identifier) @_attr
(#eq? @_attr "behaviour"))) @definition.behaviour

; British spelling variant - @behavior ModuleName
(unary_operator
operator: "@"
operand: (call
target: (identifier) @_attr
(#eq? @_attr "behavior"))) @definition.behaviour
Loading