1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
//! `deftextobject` — Lisp-authored tree-sitter text objects.
//!
//! Absorbs nvim-treesitter-textobjects into a typed declarative
//! form. A text object is a named scope over the tree-sitter AST
//! that vim operators and motions can target:
//!
//! ```text
//! vim keys what it means needs this object
//! -----------------------------------------------------------------
//! vif visually select inside function function.inner
//! daf delete a function (w/ spacing) function.outer
//! cip change inside paragraph paragraph.inner
//! vac visually select around class class.outer
//! ```
//!
//! Each text object bundles:
//!
//! - a **name** — the key suffix vim binds it to (`f` → function, `p`
//! → paragraph, `c` → class, `a` → argument).
//! - a **scope** — `inner` or `outer`. Outer swallows surrounding
//! whitespace / delimiters; inner strips them.
//! - a **query** — tree-sitter s-expression capturing the AST node
//! the object represents.
//! - an optional **filetype** — the grammar this query binds to.
//! Empty means "applies to every grammar that matches the query".
//!
//! ```lisp
//! (deftextobject :name "function"
//! :scope "outer"
//! :filetype "rust"
//! :query "(function_item) @function.outer")
//!
//! (deftextobject :name "function"
//! :scope "inner"
//! :filetype "rust"
//! :query "(function_item body: (block) @function.inner)")
//!
//! (deftextobject :name "class"
//! :scope "outer"
//! :filetype "python"
//! :query "(class_definition) @class.outer")
//! ```
//!
//! The runtime composes these with the operator/motion table: when
//! the user types `vif`, the dispatcher looks up `(f, inner)` for
//! the active buffer's filetype, runs the captured query, and
//! selects the matching AST node. Compositional with vim grammar
//! — no per-plugin keybind plumbing.
use ;
use DeriveTataraDomain;
/// The two scope kinds a text object can carry. `inner` strips the
/// surrounding delimiters (whitespace, braces, quotes); `outer`
/// includes them. Matches vim's `i`/`a` modifier grammar.
pub const KNOWN_SCOPES: & = &;
/// Canonical text-object short names used across the category —
/// `f` for function, `c` for class, `p` for paragraph, `a` for
/// argument, etc. Purely advisory — any `:name` string works.
pub const CANONICAL_NAMES: & = &;
/// True when `name` is one of the canonical single-letter aliases —
/// used for which-key rollups. Long names always work; this just
/// lets discovery UIs know the short form is "standard".