retrovim 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. package/.conda/retrovim.yaml +259 -0
  2. package/.conda/terax.icns +0 -0
  3. package/.conda/terax.ico +0 -0
  4. package/.conda/terax.png +0 -0
  5. package/.github/workflows/release.yml +95 -0
  6. package/.gitmodules +3 -0
  7. package/.npm/kanata_touchcursor.js +28 -0
  8. package/.npm/nvim.js +26 -0
  9. package/.npm/yazi.js +26 -0
  10. package/.npm/zsh.js +17 -0
  11. package/.pip/kanata_touchcursor/__init__.py +28 -0
  12. package/.pip/nvim/__init__.py +31 -0
  13. package/.pip/yazi/__init__.py +31 -0
  14. package/.pip/zsh/__init__.py +22 -0
  15. package/CHANGELOG.md +26 -0
  16. package/LICENSE +674 -0
  17. package/README.md +336 -0
  18. package/kanata/touchcursor.kbd +164 -0
  19. package/nvim/init.lua +813 -0
  20. package/nvim/plugins/mini.nvim/.github/DISCUSSION_TEMPLATE/q-a.yml +72 -0
  21. package/nvim/plugins/mini.nvim/.github/ISSUE_TEMPLATE/bug-report.yml +136 -0
  22. package/nvim/plugins/mini.nvim/.github/ISSUE_TEMPLATE/config.yml +5 -0
  23. package/nvim/plugins/mini.nvim/.github/ISSUE_TEMPLATE/feature-request.yml +75 -0
  24. package/nvim/plugins/mini.nvim/.github/PULL_REQUEST_TEMPLATE.md +2 -0
  25. package/nvim/plugins/mini.nvim/.github/workflows/quality-control.yml +150 -0
  26. package/nvim/plugins/mini.nvim/.pre-commit-config.yaml +20 -0
  27. package/nvim/plugins/mini.nvim/.stylua.toml +7 -0
  28. package/nvim/plugins/mini.nvim/.styluaignore +1 -0
  29. package/nvim/plugins/mini.nvim/CHANGELOG.md +1894 -0
  30. package/nvim/plugins/mini.nvim/CODE_OF_CONDUCT.md +132 -0
  31. package/nvim/plugins/mini.nvim/CONTRIBUTING.md +331 -0
  32. package/nvim/plugins/mini.nvim/LICENSE +21 -0
  33. package/nvim/plugins/mini.nvim/MAINTAINING.md +330 -0
  34. package/nvim/plugins/mini.nvim/Makefile +51 -0
  35. package/nvim/plugins/mini.nvim/README.md +261 -0
  36. package/nvim/plugins/mini.nvim/TESTING.md +1011 -0
  37. package/nvim/plugins/mini.nvim/benchmarks/starter/README.md +35 -0
  38. package/nvim/plugins/mini.nvim/benchmarks/starter/benchmark.sh +56 -0
  39. package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_dashboard-alpha.lua +21 -0
  40. package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_dashboard-original.lua +17 -0
  41. package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_dashboard-starter.lua +18 -0
  42. package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_empty.lua +4 -0
  43. package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_starter-default.lua +7 -0
  44. package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_startify-alpha.lua +10 -0
  45. package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_startify-original.lua +7 -0
  46. package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_startify-starter.lua +20 -0
  47. package/nvim/plugins/mini.nvim/benchmarks/starter/install.sh +10 -0
  48. package/nvim/plugins/mini.nvim/benchmarks/starter/make_summary.py +68 -0
  49. package/nvim/plugins/mini.nvim/benchmarks/starter/startup-summary.md +10 -0
  50. package/nvim/plugins/mini.nvim/colors/miniautumn.lua +55 -0
  51. package/nvim/plugins/mini.nvim/colors/minicyan.lua +95 -0
  52. package/nvim/plugins/mini.nvim/colors/minischeme.lua +95 -0
  53. package/nvim/plugins/mini.nvim/colors/minispring.lua +53 -0
  54. package/nvim/plugins/mini.nvim/colors/minisummer.lua +49 -0
  55. package/nvim/plugins/mini.nvim/colors/miniwinter.lua +51 -0
  56. package/nvim/plugins/mini.nvim/colors/randomhue.lua +16 -0
  57. package/nvim/plugins/mini.nvim/doc/mini-ai.txt +889 -0
  58. package/nvim/plugins/mini.nvim/doc/mini-align.txt +923 -0
  59. package/nvim/plugins/mini.nvim/doc/mini-animate.txt +937 -0
  60. package/nvim/plugins/mini.nvim/doc/mini-base16.txt +285 -0
  61. package/nvim/plugins/mini.nvim/doc/mini-basics.txt +359 -0
  62. package/nvim/plugins/mini.nvim/doc/mini-bracketed.txt +622 -0
  63. package/nvim/plugins/mini.nvim/doc/mini-bufremove.txt +123 -0
  64. package/nvim/plugins/mini.nvim/doc/mini-clue.txt +760 -0
  65. package/nvim/plugins/mini.nvim/doc/mini-cmdline.txt +392 -0
  66. package/nvim/plugins/mini.nvim/doc/mini-colors.txt +880 -0
  67. package/nvim/plugins/mini.nvim/doc/mini-comment.txt +230 -0
  68. package/nvim/plugins/mini.nvim/doc/mini-completion.txt +477 -0
  69. package/nvim/plugins/mini.nvim/doc/mini-cursorword.txt +105 -0
  70. package/nvim/plugins/mini.nvim/doc/mini-deps.txt +590 -0
  71. package/nvim/plugins/mini.nvim/doc/mini-diff.txt +661 -0
  72. package/nvim/plugins/mini.nvim/doc/mini-doc.txt +434 -0
  73. package/nvim/plugins/mini.nvim/doc/mini-extra.txt +856 -0
  74. package/nvim/plugins/mini.nvim/doc/mini-files.txt +1018 -0
  75. package/nvim/plugins/mini.nvim/doc/mini-fuzzy.txt +160 -0
  76. package/nvim/plugins/mini.nvim/doc/mini-git.txt +425 -0
  77. package/nvim/plugins/mini.nvim/doc/mini-hipatterns.txt +489 -0
  78. package/nvim/plugins/mini.nvim/doc/mini-hues.txt +420 -0
  79. package/nvim/plugins/mini.nvim/doc/mini-icons.txt +508 -0
  80. package/nvim/plugins/mini.nvim/doc/mini-indentscope.txt +485 -0
  81. package/nvim/plugins/mini.nvim/doc/mini-input.txt +932 -0
  82. package/nvim/plugins/mini.nvim/doc/mini-jump.txt +202 -0
  83. package/nvim/plugins/mini.nvim/doc/mini-jump2d.txt +525 -0
  84. package/nvim/plugins/mini.nvim/doc/mini-keymap.txt +449 -0
  85. package/nvim/plugins/mini.nvim/doc/mini-map.txt +717 -0
  86. package/nvim/plugins/mini.nvim/doc/mini-misc.txt +431 -0
  87. package/nvim/plugins/mini.nvim/doc/mini-move.txt +181 -0
  88. package/nvim/plugins/mini.nvim/doc/mini-notify.txt +434 -0
  89. package/nvim/plugins/mini.nvim/doc/mini-nvim.txt +431 -0
  90. package/nvim/plugins/mini.nvim/doc/mini-operators.txt +472 -0
  91. package/nvim/plugins/mini.nvim/doc/mini-pairs.txt +346 -0
  92. package/nvim/plugins/mini.nvim/doc/mini-pick.txt +1535 -0
  93. package/nvim/plugins/mini.nvim/doc/mini-sessions.txt +239 -0
  94. package/nvim/plugins/mini.nvim/doc/mini-snippets.txt +1291 -0
  95. package/nvim/plugins/mini.nvim/doc/mini-splitjoin.txt +536 -0
  96. package/nvim/plugins/mini.nvim/doc/mini-starter.txt +618 -0
  97. package/nvim/plugins/mini.nvim/doc/mini-statusline.txt +361 -0
  98. package/nvim/plugins/mini.nvim/doc/mini-surround.txt +863 -0
  99. package/nvim/plugins/mini.nvim/doc/mini-tabline.txt +151 -0
  100. package/nvim/plugins/mini.nvim/doc/mini-test.txt +966 -0
  101. package/nvim/plugins/mini.nvim/doc/mini-trailspace.txt +91 -0
  102. package/nvim/plugins/mini.nvim/doc/mini-visits.txt +937 -0
  103. package/nvim/plugins/mini.nvim/logo.png +0 -0
  104. package/nvim/plugins/mini.nvim/lua/mini/ai.lua +2244 -0
  105. package/nvim/plugins/mini.nvim/lua/mini/align.lua +2076 -0
  106. package/nvim/plugins/mini.nvim/lua/mini/animate.lua +2127 -0
  107. package/nvim/plugins/mini.nvim/lua/mini/base16.lua +1752 -0
  108. package/nvim/plugins/mini.nvim/lua/mini/basics.lua +772 -0
  109. package/nvim/plugins/mini.nvim/lua/mini/bracketed.lua +2013 -0
  110. package/nvim/plugins/mini.nvim/lua/mini/bufremove.lua +283 -0
  111. package/nvim/plugins/mini.nvim/lua/mini/clue.lua +2096 -0
  112. package/nvim/plugins/mini.nvim/lua/mini/cmdline.lua +1182 -0
  113. package/nvim/plugins/mini.nvim/lua/mini/colors.lua +2483 -0
  114. package/nvim/plugins/mini.nvim/lua/mini/comment.lua +586 -0
  115. package/nvim/plugins/mini.nvim/lua/mini/completion.lua +2094 -0
  116. package/nvim/plugins/mini.nvim/lua/mini/cursorword.lua +311 -0
  117. package/nvim/plugins/mini.nvim/lua/mini/deps.lua +1660 -0
  118. package/nvim/plugins/mini.nvim/lua/mini/diff.lua +1938 -0
  119. package/nvim/plugins/mini.nvim/lua/mini/doc.lua +1371 -0
  120. package/nvim/plugins/mini.nvim/lua/mini/extra.lua +2290 -0
  121. package/nvim/plugins/mini.nvim/lua/mini/files.lua +3145 -0
  122. package/nvim/plugins/mini.nvim/lua/mini/fuzzy.lua +356 -0
  123. package/nvim/plugins/mini.nvim/lua/mini/git.lua +1737 -0
  124. package/nvim/plugins/mini.nvim/lua/mini/hipatterns.lua +1042 -0
  125. package/nvim/plugins/mini.nvim/lua/mini/hues.lua +2088 -0
  126. package/nvim/plugins/mini.nvim/lua/mini/icons.lua +2254 -0
  127. package/nvim/plugins/mini.nvim/lua/mini/indentscope.lua +1158 -0
  128. package/nvim/plugins/mini.nvim/lua/mini/init.lua +427 -0
  129. package/nvim/plugins/mini.nvim/lua/mini/input.lua +2183 -0
  130. package/nvim/plugins/mini.nvim/lua/mini/jump.lua +609 -0
  131. package/nvim/plugins/mini.nvim/lua/mini/jump2d.lua +1244 -0
  132. package/nvim/plugins/mini.nvim/lua/mini/keymap.lua +880 -0
  133. package/nvim/plugins/mini.nvim/lua/mini/map.lua +1709 -0
  134. package/nvim/plugins/mini.nvim/lua/mini/misc.lua +969 -0
  135. package/nvim/plugins/mini.nvim/lua/mini/move.lua +509 -0
  136. package/nvim/plugins/mini.nvim/lua/mini/notify.lua +938 -0
  137. package/nvim/plugins/mini.nvim/lua/mini/operators.lua +1349 -0
  138. package/nvim/plugins/mini.nvim/lua/mini/pairs.lua +657 -0
  139. package/nvim/plugins/mini.nvim/lua/mini/pick.lua +3876 -0
  140. package/nvim/plugins/mini.nvim/lua/mini/sessions.lua +689 -0
  141. package/nvim/plugins/mini.nvim/lua/mini/snippets.lua +2828 -0
  142. package/nvim/plugins/mini.nvim/lua/mini/splitjoin.lua +1132 -0
  143. package/nvim/plugins/mini.nvim/lua/mini/starter.lua +1599 -0
  144. package/nvim/plugins/mini.nvim/lua/mini/statusline.lua +686 -0
  145. package/nvim/plugins/mini.nvim/lua/mini/surround.lua +2388 -0
  146. package/nvim/plugins/mini.nvim/lua/mini/tabline.lua +564 -0
  147. package/nvim/plugins/mini.nvim/lua/mini/test.lua +2516 -0
  148. package/nvim/plugins/mini.nvim/lua/mini/trailspace.lua +215 -0
  149. package/nvim/plugins/mini.nvim/lua/mini/visits.lua +1577 -0
  150. package/nvim/plugins/mini.nvim/readmes/mini-ai.md +190 -0
  151. package/nvim/plugins/mini.nvim/readmes/mini-align.md +203 -0
  152. package/nvim/plugins/mini.nvim/readmes/mini-animate.md +214 -0
  153. package/nvim/plugins/mini.nvim/readmes/mini-base16.md +198 -0
  154. package/nvim/plugins/mini.nvim/readmes/mini-basics.md +184 -0
  155. package/nvim/plugins/mini.nvim/readmes/mini-bracketed.md +193 -0
  156. package/nvim/plugins/mini.nvim/readmes/mini-bufremove.md +139 -0
  157. package/nvim/plugins/mini.nvim/readmes/mini-clue.md +260 -0
  158. package/nvim/plugins/mini.nvim/readmes/mini-cmdline.md +183 -0
  159. package/nvim/plugins/mini.nvim/readmes/mini-colors.md +169 -0
  160. package/nvim/plugins/mini.nvim/readmes/mini-comment.md +183 -0
  161. package/nvim/plugins/mini.nvim/readmes/mini-completion.md +217 -0
  162. package/nvim/plugins/mini.nvim/readmes/mini-cursorword.md +137 -0
  163. package/nvim/plugins/mini.nvim/readmes/mini-deps.md +271 -0
  164. package/nvim/plugins/mini.nvim/readmes/mini-diff.md +289 -0
  165. package/nvim/plugins/mini.nvim/readmes/mini-doc.md +198 -0
  166. package/nvim/plugins/mini.nvim/readmes/mini-extra.md +158 -0
  167. package/nvim/plugins/mini.nvim/readmes/mini-files.md +247 -0
  168. package/nvim/plugins/mini.nvim/readmes/mini-fuzzy.md +134 -0
  169. package/nvim/plugins/mini.nvim/readmes/mini-git.md +168 -0
  170. package/nvim/plugins/mini.nvim/readmes/mini-hipatterns.md +176 -0
  171. package/nvim/plugins/mini.nvim/readmes/mini-hues.md +285 -0
  172. package/nvim/plugins/mini.nvim/readmes/mini-icons.md +183 -0
  173. package/nvim/plugins/mini.nvim/readmes/mini-indentscope.md +191 -0
  174. package/nvim/plugins/mini.nvim/readmes/mini-input.md +163 -0
  175. package/nvim/plugins/mini.nvim/readmes/mini-jump.md +161 -0
  176. package/nvim/plugins/mini.nvim/readmes/mini-jump2d.md +197 -0
  177. package/nvim/plugins/mini.nvim/readmes/mini-keymap.md +205 -0
  178. package/nvim/plugins/mini.nvim/readmes/mini-map.md +191 -0
  179. package/nvim/plugins/mini.nvim/readmes/mini-misc.md +145 -0
  180. package/nvim/plugins/mini.nvim/readmes/mini-move.md +163 -0
  181. package/nvim/plugins/mini.nvim/readmes/mini-notify.md +175 -0
  182. package/nvim/plugins/mini.nvim/readmes/mini-operators.md +193 -0
  183. package/nvim/plugins/mini.nvim/readmes/mini-pairs.md +158 -0
  184. package/nvim/plugins/mini.nvim/readmes/mini-pick.md +340 -0
  185. package/nvim/plugins/mini.nvim/readmes/mini-sessions.md +164 -0
  186. package/nvim/plugins/mini.nvim/readmes/mini-snippets.md +373 -0
  187. package/nvim/plugins/mini.nvim/readmes/mini-splitjoin.md +194 -0
  188. package/nvim/plugins/mini.nvim/readmes/mini-starter.md +176 -0
  189. package/nvim/plugins/mini.nvim/readmes/mini-statusline.md +155 -0
  190. package/nvim/plugins/mini.nvim/readmes/mini-surround.md +190 -0
  191. package/nvim/plugins/mini.nvim/readmes/mini-tabline.md +156 -0
  192. package/nvim/plugins/mini.nvim/readmes/mini-test.md +175 -0
  193. package/nvim/plugins/mini.nvim/readmes/mini-trailspace.md +137 -0
  194. package/nvim/plugins/mini.nvim/readmes/mini-visits.md +243 -0
  195. package/nvim/plugins/mini.nvim/scripts/dual_log.sh +13 -0
  196. package/nvim/plugins/mini.nvim/scripts/dual_push.sh +15 -0
  197. package/nvim/plugins/mini.nvim/scripts/dual_release.sh +102 -0
  198. package/nvim/plugins/mini.nvim/scripts/dual_sync.sh +115 -0
  199. package/nvim/plugins/mini.nvim/scripts/init-deps-example.lua +59 -0
  200. package/nvim/plugins/mini.nvim/scripts/lint-filename-length.sh +16 -0
  201. package/nvim/plugins/mini.nvim/scripts/lintcommit-ci.sh +18 -0
  202. package/nvim/plugins/mini.nvim/scripts/lintcommit.lua +393 -0
  203. package/nvim/plugins/mini.nvim/scripts/minidoc.lua +57 -0
  204. package/nvim/plugins/mini.nvim/scripts/minimal_init.lua +28 -0
  205. package/nvim/plugins/mini.nvim/scripts/minitest.lua +4 -0
  206. package/package.json +16 -0
  207. package/pyproject.toml +43 -0
  208. package/yazi/init.lua +12 -0
  209. package/yazi/keymap.toml +114 -0
  210. package/yazi/lesskey +5 -0
  211. package/yazi/plugins/bookmarks.yazi/main.lua +86 -0
  212. package/yazi/plugins/cd-git-root.yazi/main.lua +31 -0
  213. package/yazi/plugins/smart-enter.yazi/main.lua +11 -0
  214. package/yazi/theme.toml +26 -0
  215. package/yazi/yazi.toml +15 -0
  216. package/zsh/.zshrc +145 -0
  217. package/zsh/starship.toml +20 -0
  218. package/zsh/zsh-patina.toml +2 -0
@@ -0,0 +1,889 @@
1
+ *mini.ai* Extend and create a/i textobjects
2
+
3
+ MIT License Copyright (c) 2022 Evgeni Chasnovski
4
+
5
+ ------------------------------------------------------------------------------
6
+ *MiniAi*
7
+ Enhance some builtin |text-objects| (like |a(|, |a)|, |a'|, and more),
8
+ create new ones (like `a*`, `a<Space>`, `af`, `a?`, and more), and allow
9
+ user to create their own.
10
+
11
+ Features:
12
+ - Customizable creation of `a`/`i` textobjects using Lua patterns and functions.
13
+ Supports:
14
+ - Dot-repeat.
15
+ - |v:count|.
16
+ - Different search methods (see |MiniAi.config|).
17
+ - Consecutive application (update selection without leaving Visual mode).
18
+ - Aliases for multiple textobjects.
19
+
20
+ - Comprehensive builtin textobjects (see more in |MiniAi-builtin-textobjects|):
21
+ - Balanced brackets (with and without whitespace) plus alias.
22
+ - Balanced quotes plus alias.
23
+ - Function call.
24
+ - Argument.
25
+ - Tag.
26
+ - Derived from user prompt.
27
+ - Default for anything but Latin letters (to fall back to |text-objects|).
28
+
29
+ For more textobjects see |MiniExtra.gen_ai_spec|.
30
+
31
+ - Motions for jumping to left/right edge of textobject.
32
+
33
+ - Set of specification generators to tweak some builtin textobjects (see
34
+ |MiniAi.gen_spec|).
35
+
36
+ - Treesitter textobjects (through |MiniAi.gen_spec.treesitter()| helper).
37
+
38
+ This module works by defining mappings for both `a` and `i` in Visual and
39
+ Operator-pending mode. After typing, they wait for single character user input
40
+ treated as textobject identifier and apply resolved textobject specification
41
+ (fall back to other mappings if can't find proper textobject id). For more
42
+ information see |MiniAi-textobject-specification| and |MiniAi-algorithm|.
43
+
44
+ Known issues which won't be resolved:
45
+ - Search for builtin textobjects is done mostly using Lua patterns
46
+ (regex-like approach). Certain amount of false positives is to be expected.
47
+
48
+ - During search for builtin textobjects there is no distinction if it is
49
+ inside string or comment. For example, in the following case there will
50
+ be wrong match for a function call: `f(a = ")", b = 1)`.
51
+
52
+ General rule of thumb: any instrument using available parser for document
53
+ structure (like treesitter) will usually provide more precise results. This
54
+ module has builtins mostly for plain text textobjects which are useful
55
+ most of the times (like "inside brackets", "around quotes/underscore", etc.).
56
+ For advanced use cases define function specification for custom textobjects.
57
+
58
+ What it doesn't (and probably won't) do:
59
+ - Have special operators to specially handle whitespace (like `I` and `A`
60
+ in `wellle/targets.vim`). Whitespace handling is assumed to be done inside
61
+ textobject specification (like `i(` and `i)` handle whitespace differently).
62
+
63
+ # Setup ~
64
+
65
+ This module needs a setup with `require('mini.ai').setup({})` (replace
66
+ `{}` with your `config` table). It will create global Lua table `MiniAi`
67
+ which you can use for scripting or manually (with `:lua MiniAi.*`).
68
+
69
+ See |MiniAi.config| for available config settings.
70
+
71
+ You can override runtime config settings (like `config.custom_textobjects`)
72
+ locally to buffer inside `vim.b.miniai_config` which should have same structure
73
+ as `MiniAi.config`. See |mini.nvim-buffer-local-config| for more details.
74
+
75
+ To stop module from showing non-error feedback, set `config.silent = true`.
76
+
77
+ # Comparisons ~
78
+
79
+ - [wellle/targets.vim](https://github.com/wellle/targets.vim):
80
+ - Has limited support for creating own textobjects: it is constrained
81
+ to pre-defined detection rules. |mini.ai| allows creating own rules
82
+ via Lua patterns and functions (see |MiniAi-textobject-specification|).
83
+ - Doesn't provide any programmatical API for getting information about
84
+ textobjects. |mini.ai| does it via |MiniAi.find_textobject()|.
85
+ - Has no implementation of "moving to edge of textobject". |mini.ai|
86
+ does it via |MiniAi.move_cursor()| and `g[` and `g]` default mappings.
87
+ - Both implement the notion of manual "next"/"last" search directions.
88
+ - Implements `A`, `I` operators. |mini.ai| does not by design: it is
89
+ assumed to be a property of textobject, not operator.
90
+ - Doesn't implement "function call" and "user prompt" textobjects.
91
+ |mini.ai| does (with `f` and `?` identifiers).
92
+ - Has limited support for "argument" textobject. Although it works in
93
+ most situations, it often misdetects commas as argument separator
94
+ (like if it is inside quotes or `{}`). |mini.ai| deals with these cases.
95
+ - [nvim-treesitter/nvim-treesitter-textobjects](https://github.com/nvim-treesitter/nvim-treesitter-textobjects):
96
+ - Along with textobject functionality provides a curated and maintained
97
+ set of popular textobject queries for many languages (which can power
98
+ |MiniAi.gen_spec.treesitter()| functionality).
99
+ - Both support working with |treesitter-directives| allowing more
100
+ fine-tuned textobjects.
101
+ - Implements only textobjects based on treesitter.
102
+ - Doesn't support |v:count|.
103
+ - Doesn't support multiple search method (basically, only `'cover'`).
104
+ - Doesn't support consecutive application of target textobject.
105
+
106
+ # Disabling ~
107
+
108
+ To disable, set `vim.g.miniai_disable` (globally) or `vim.b.miniai_disable`
109
+ (for a buffer) to `true`. Considering high number of different scenarios
110
+ and customization intentions, writing exact rules for disabling module's
111
+ functionality is left to user. See |mini.nvim-disabling-recipes| for common
112
+ recipes.
113
+
114
+ ------------------------------------------------------------------------------
115
+ *MiniAi-builtin-textobjects*
116
+ This table describes all builtin textobjects along with what they
117
+ represent. Explanation:
118
+ - `Key` represents the textobject identifier: single character which should
119
+ be typed after `a`/`i`.
120
+ - `Name` is a description of textobject.
121
+ - `Example line` contains a string for which examples are constructed. The
122
+ `*` denotes the cursor position.
123
+ - `a`/`i` describe inclusive region representing `a` and `i` textobjects.
124
+ Use numbers in separators for easier navigation.
125
+ - `2a`/`2i` describe either `2a`/`2i` (support for |v:count|) textobjects
126
+ or `a`/`i` textobject followed by another `a`/`i` textobject (consecutive
127
+ application leads to incremental selection).
128
+
129
+ Example: typing `va)` with cursor on `*` leads to selection from column 2
130
+ to column 12. Another typing `a)` changes selection to [1; 13]. Also, besides
131
+ visual selection, any |operator| can be used or `g[`/`g]` motions to move
132
+ to left/right edge of `a` textobject.
133
+ >
134
+ ┌───┬───────────────┬──────────────────┬────────┬────────┬────────┬────────┐
135
+ │Key│ Name │ Example line │ a │ i │ 2a │ 2i │
136
+ ├───┴───────────────┴──────────────────┴────────┴────────┴────────┴────────┤
137
+ ├┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈1234567890123456┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┤
138
+ │ ( │ Balanced () │ (( *a (bb) )) │ │ │ │ │
139
+ │ [ │ Balanced [] │ [[ *a [bb] ]] │ [2;12] │ [4;10] │ [1;13] │ [2;12] │
140
+ │ { │ Balanced {} │ {{ *a {bb} }} │ │ │ │ │
141
+ │ < │ Balanced <> │ << *a <bb> >> │ │ │ │ │
142
+ ├┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈1234567890123456┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┤
143
+ │ ) │ Balanced () │ (( *a (bb) )) │ │ │ │ │
144
+ │ ] │ Balanced [] │ [[ *a [bb] ]] │ │ │ │ │
145
+ │ } │ Balanced {} │ {{ *a {bb} }} │ [2;12] │ [3;11] │ [1;13] │ [2;12] │
146
+ │ > │ Balanced <> │ << *a <bb> >> │ │ │ │ │
147
+ │ b │ Alias for │ [( *a {bb} )] │ │ │ │ │
148
+ │ │ ), ], or } │ │ │ │ │ │
149
+ ├┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈1234567890123456┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┤
150
+ │ " │ Balanced " │ "*a" " bb " │ │ │ │ │
151
+ │ ' │ Balanced ' │ '*a' ' bb ' │ │ │ │ │
152
+ │ ` │ Balanced ` │ `*a` ` bb ` │ [1;4] │ [2;3] │ [6;11] │ [7;10] │
153
+ │ q │ Alias for │ '*a' " bb " │ │ │ │ │
154
+ │ │ ", ', or ` │ │ │ │ │ │
155
+ ├┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈1234567890123456┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┤
156
+ │ ? │ User prompt │ e*e o e o o │ [3;5] │ [4;4] │ [7;9] │ [8;8] │
157
+ │ │(typed e and o)│ │ │ │ │ │
158
+ ├┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈1234567890123456┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┤
159
+ │ t │ Tag │ <x><y>*a</y></x> │ [4;12] │ [7;8] │ [1;16] │ [4;12] │
160
+ ├┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈1234567890123456┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┤
161
+ │ f │ Function call │ f(a, g(*b, c) ) │ [6;13] │ [8;12] │ [1;15] │ [3;14] │
162
+ ├┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈1234567890123456┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┤
163
+ │ a │ Argument │ f(*a, g(b, c) ) │ [3;5] │ [3;4] │ [5;14] │ [7;13] │
164
+ ├┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈1234567890123456┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┤
165
+ │ │ Default │ aa_*b__cc___ │ [4;7] │ [4;5] │ [8;12] │ [8;9] │
166
+ │ │ (typed _) │ │ │ │ │ │
167
+ └───┴───────────────┴──────────────────┴────────┴────────┴────────┴────────┘
168
+ <
169
+ Notes:
170
+ - All examples assume default `config.search_method`.
171
+ - Open brackets differ from close brackets by how they treat inner edge
172
+ whitespace for `i` textobject: open ignores it, close - includes.
173
+ - Default textobject is activated for identifiers which are not Latin letters.
174
+ They are designed to be treated as separators, so include only right edge
175
+ in `a` textobject. To include both edges, use custom textobjects
176
+ (see |MiniAi-textobject-specification| and |MiniAi.config|). Note:
177
+ - When cursor is exactly on the identifier character while there are
178
+ two matching candidates on both left and right, the resulting region
179
+ with smaller width is preferred.
180
+
181
+ ------------------------------------------------------------------------------
182
+ *MiniAi-glossary*
183
+ Note: this is similar to |MiniSurround-glossary|.
184
+
185
+ REGION ~
186
+ Table representing region in a buffer. Fields:
187
+ - <from> and <to> for inclusive start and end positions (<to> might be
188
+ `nil` to describe empty region). Each position is also a table with
189
+ line <line> and column <col> (both start at 1).
190
+ - <vis_mode> for which Visual mode will be used to select textobject.
191
+ See `opts` argument of |MiniAi.select_textobject()|.
192
+ One of `'v'`, `'V'`, `'\22'` (escaped `'<C-v>'`).
193
+
194
+ Examples: >lua
195
+
196
+ { from = { line = 1, col = 1 }, to = { line = 2, col = 1 } }
197
+
198
+ -- Forced linewise mode
199
+ {
200
+ from = { line = 1, col = 1 }, to = { line = 2, col = 1 },
201
+ vis_mode = 'V',
202
+ }
203
+
204
+ -- Empty region
205
+ { from = { line = 10, col = 10 } }
206
+ <
207
+ PATTERN ~
208
+ String describing Lua pattern.
209
+
210
+ SPAN ~
211
+ Interval inside a string (end-exclusive). Like [1, 5). Equal `from` and `to` edges
212
+ describe empty span at that point.
213
+
214
+ Span `A = [a1, a2)` covers `B = [b1, b2)` if every element of `B` is within
215
+ `A` (`a1 <= b < a2`). It also is described as "B is nested inside A".
216
+
217
+ NESTED PATTERN ~
218
+ Array of patterns aimed to describe nested spans.
219
+
220
+ SPAN MATCHES NESTED PATTERN ~
221
+ If there is a sequence of consecutively nested spans each matching
222
+ corresponding pattern within substring of previous span (or input string
223
+ for first span). Example: >lua
224
+
225
+ -- Nested patterns for balanced `()` with inner space
226
+ { '%b()', '^. .* .$' }
227
+
228
+ -- Example input string (with columns underneath for easier reading):
229
+ "( ( () ( ) ) )"
230
+ -- 12345678901234
231
+ <
232
+ Here are all matching spans [1, 15) and [3, 13). Both [5, 7) and [8, 10)
233
+ match first pattern but not second. All other combinations of `(` and `)`
234
+ don't match first pattern (not balanced).
235
+
236
+ COMPOSED PATTERN ~
237
+ Array with each element describing possible pattern (or array of them) at
238
+ that place. Composed pattern basically defines all possible combinations of
239
+ nested pattern (their cartesian product). Examples:
240
+
241
+ 1. Either balanced `()` or balanced `[]` but both with inner edge space: >lua
242
+
243
+ -- Composed pattern
244
+ { { '%b()', '%b[]' }, '^. .* .$' }
245
+
246
+ -- Composed pattern expanded into equivalent array of nested patterns
247
+ { '%b()', '^. .* .$' } -- and
248
+ { '%b[]', '^. .* .$' }
249
+ <
250
+ 2. Either "balanced `()` with inner edge space" or "balanced `[]` with no
251
+ inner edge space", both with 5 or more characters: >lua
252
+
253
+ -- Composed pattern
254
+ { { { '%b()', '^. .* .$' }, { '%b[]', '^.[^ ].*[^ ].$' } }, '.....' }
255
+
256
+ -- Composed pattern expanded into equivalent array of nested patterns
257
+ { '%b()', '^. .* .$', '.....' } -- and
258
+ { '%b[]', '^.[^ ].*[^ ].$', '.....' }
259
+ <
260
+ SPAN MATCHES COMPOSED PATTERN ~
261
+ If it matches at least one nested pattern from expanded composed pattern.
262
+
263
+ ------------------------------------------------------------------------------
264
+ *MiniAi-textobject-specification*
265
+ Textobject specification has a structure of composed pattern (see
266
+ |MiniAi-glossary|) with two differences:
267
+ - Last pattern(s) should have even number of empty capture groups denoting
268
+ how the last string should be processed to extract `a` or `i` textobject:
269
+ - Zero captures mean that whole string represents both `a` and `i`.
270
+ Example: `xxx` will define textobject matching string `xxx` literally.
271
+ - Two captures represent `i` textobject inside of them. `a` - whole string.
272
+ Example: `x()x()x` defines `a` textobject to be `xxx`, `i` - middle `x`.
273
+ - Four captures define `a` textobject inside captures 1 and 4, `i` -
274
+ inside captures 2 and 3. Example: `x()()x()x()` defines `a`
275
+ textobject to be last `xx`, `i` - middle `x`.
276
+ - Allows callable objects (see |vim.is_callable()|) in certain places
277
+ (enables more complex textobjects in exchange of increase in configuration
278
+ complexity and computations):
279
+ - If specification itself is a callable, it will be called with the same
280
+ arguments as |MiniAi.find_textobject()| and should return one of:
281
+ - Composed pattern. Useful for implementing user input. Example of
282
+ simplified variant of textobject for function call with name taken
283
+ from user prompt: >lua
284
+
285
+ function()
286
+ local left_edge = vim.pesc(vim.fn.input('Function name: '))
287
+ return { left_edge .. '%b()', '^.-%(().*()%)$' }
288
+ end
289
+ <
290
+ - Single output region. Useful to allow full control over
291
+ textobject. Will be taken as is. Example of returning whole buffer: >lua
292
+
293
+ function()
294
+ local from = { line = 1, col = 1 }
295
+ local to = {
296
+ line = vim.fn.line('$'),
297
+ col = math.max(vim.fn.getline('$'):len(), 1)
298
+ }
299
+ return { from = from, to = to, vis_mode = 'V' }
300
+ end
301
+ <
302
+ - Array of output region(s). Useful for incorporating other
303
+ instruments, like treesitter (see |MiniAi.gen_spec.treesitter()|).
304
+ The best region will be picked in the same manner as with composed
305
+ pattern (respecting options `n_lines`, `search_method`, etc.).
306
+ Example of selecting "best" line with display width more than 80: >lua
307
+
308
+ function(_, _, _)
309
+ local res = {}
310
+ for i = 1, vim.api.nvim_buf_line_count(0) do
311
+ local cur_line = vim.fn.getline(i)
312
+ if vim.fn.strdisplaywidth(cur_line) > 80 then
313
+ local region = {
314
+ from = { line = i, col = 1 },
315
+ to = { line = i, col = cur_line:len() },
316
+ }
317
+ table.insert(res, region)
318
+ end
319
+ end
320
+ return res
321
+ end
322
+ <
323
+ - If there is a callable instead of assumed string pattern, it is expected
324
+ to have signature `(line, init)` and behave like `pattern:find()`.
325
+ It should return two numbers representing span in `line` next after
326
+ or at `init` (`nil` if there is no such span).
327
+ !IMPORTANT NOTE!: it means that output's `from` shouldn't be strictly
328
+ to the left of `init` (it will lead to infinite loop). Not allowed as
329
+ last item (as it should be pattern with captures).
330
+ Example of matching only balanced parenthesis with big enough width: >lua
331
+
332
+ {
333
+ '%b()',
334
+ function(s, init)
335
+ if init > 1 or s:len() < 5 then return end
336
+ return 1, s:len()
337
+ end,
338
+ '^.().*().$'
339
+ }
340
+ <
341
+ More examples: >lua
342
+
343
+ -- Pair of balanced brackets from set (used for builtin `b` identifier):
344
+ { { '%b()', '%b[]', '%b{}' }, '^.().*().$' }
345
+
346
+ -- Imitate word ignoring digits and punctuation (only for Latin alphabet):
347
+ { '()()%f[%w]%w+()[ \t]*()' }
348
+
349
+ -- Word with camel case support (also supports only Latin alphabet):
350
+ {
351
+ {
352
+ '%u[%l%d]+%f[^%l%d]',
353
+ '%f[%S][%l%d]+%f[^%l%d]',
354
+ '%f[%P][%l%d]+%f[^%l%d]',
355
+ '^[%l%d]+%f[^%l%d]',
356
+ },
357
+ '^().*()$'
358
+ }
359
+
360
+ -- Number:
361
+ { '%f[%d]%d+' }
362
+
363
+ -- Date in 'YYYY-MM-DD' format:
364
+ { '()%d%d%d%d%-%d%d%-%d%d()' }
365
+
366
+ -- Lua block string:
367
+ { '%[%[().-()%]%]' }
368
+ <
369
+ See |MiniAi.gen_spec| for function wrappers to create commonly used
370
+ textobject specifications.
371
+
372
+ ------------------------------------------------------------------------------
373
+ *MiniAi-algorithm*
374
+ Search for the textobjects relies on these principles:
375
+ - It uses same input data as described in |MiniAi.find_textobject()|,
376
+ i.e. whether it is `a` or `i` textobject, its identifier, reference region, etc.
377
+ - Textobject specification is constructed based on textobject identifier
378
+ (see |MiniAi-textobject-specification|).
379
+ - General search is done by converting some 2d buffer region (neighborhood
380
+ of reference region) into 1d string (each line is appended with `\n`).
381
+ Then search for a best span matching textobject specification is done
382
+ inside string (see |MiniAi-glossary|). After that, span is converted back
383
+ into 2d region. Note: first search is done inside reference region lines,
384
+ and only after that - inside its neighborhood within `config.n_lines`
385
+ (see |MiniAi.config|).
386
+ - The best matching span is chosen by iterating over all spans matching
387
+ textobject specification and comparing them with "current best".
388
+ Comparison also depends on reference region (tighter covering is better,
389
+ otherwise closer is better) and search method (if span is even considered).
390
+ - Extract span based on extraction pattern (last item in nested pattern).
391
+ - If task is to perform a consecutive search (`opts.n_times` is greater than 1),
392
+ steps are repeated with current best match becoming reference region.
393
+ One such additional step is also done if final region is equal to
394
+ reference region (this enables consecutive application).
395
+
396
+ Notes:
397
+ - Iteration over all matched spans is done in depth-first fashion with
398
+ respect to nested pattern.
399
+ - It is guaranteed that span is compared only once.
400
+ - For the sake of increasing functionality, during iteration over all
401
+ matching spans, some Lua patterns in composed pattern are handled
402
+ specially.
403
+ - `%bxx` (`xx` is two identical characters). It denotes balanced pair
404
+ of identical characters and results into "paired" matches. For
405
+ example, `%b""` for `"aa" "bb"` would match `"aa"` and `"bb"`, but
406
+ not middle `" "`.
407
+ - `x.-y` (`x` and `y` are different strings). It results only in matches with
408
+ smallest width. For example, `e.-o` for `e e o o` will result only in
409
+ middle `e o`. Note: it has some implications for when parts have
410
+ quantifiers (like `+`, etc.), which usually can be resolved with
411
+ frontier pattern `%f[]` (see examples in |MiniAi-textobject-specification|).
412
+
413
+ ------------------------------------------------------------------------------
414
+ *MiniAi.setup()*
415
+ `MiniAi.setup`({config})
416
+ Module setup
417
+
418
+ Parameters ~
419
+ {config} `(table|nil)` Module config table. See |MiniAi.config|.
420
+
421
+ Usage ~
422
+ >lua
423
+ require('mini.ai').setup() -- use default config
424
+ -- OR
425
+ require('mini.ai').setup({}) -- replace {} with your config table
426
+ <
427
+ ------------------------------------------------------------------------------
428
+ *MiniAi.config*
429
+ `MiniAi.config`
430
+ Defaults ~
431
+ >lua
432
+ MiniAi.config = {
433
+ -- Table with textobject id as fields, textobject specification as values.
434
+ -- Also use this to disable builtin textobjects. See |MiniAi.config|.
435
+ custom_textobjects = nil,
436
+
437
+ -- Module mappings. Use `''` (empty string) to disable one.
438
+ mappings = {
439
+ -- Main textobject prefixes
440
+ around = 'a',
441
+ inside = 'i',
442
+
443
+ -- Next/last textobjects
444
+ -- NOTE: This (deliberately) overrides Neovim>=0.12 built-in incremental
445
+ -- selection mappings. See `:h MiniAi-default-an-in` for more details.
446
+ around_next = 'an',
447
+ inside_next = 'in',
448
+ around_last = 'al',
449
+ inside_last = 'il',
450
+
451
+ -- Move cursor to corresponding edge of `a` textobject
452
+ goto_left = 'g[',
453
+ goto_right = 'g]',
454
+ },
455
+
456
+ -- Number of lines within which textobject is searched
457
+ n_lines = 50,
458
+
459
+ -- How to search for object (first inside current line, then inside
460
+ -- neighborhood). One of 'cover', 'cover_or_next', 'cover_or_prev',
461
+ -- 'cover_or_nearest', 'next', 'prev', 'nearest'.
462
+ search_method = 'cover_or_next',
463
+
464
+ -- Whether to disable showing non-error feedback
465
+ -- This also affects (purely informational) helper messages shown after
466
+ -- idle time if user input is required.
467
+ silent = false,
468
+ }
469
+ <
470
+ # Custom textobjects ~
471
+
472
+ User can define own textobjects by supplying `config.custom_textobjects`.
473
+ It should be a table with keys being single character textobject identifier
474
+ (supported by |getcharstr()|, except <Esc> and <C-c> which are used to cancel)
475
+ and values - textobject specification (see |MiniAi-textobject-specification|).
476
+
477
+ General recommendations:
478
+ - This can be used to override builtin ones (|MiniAi-builtin-textobjects|).
479
+ Supply non-valid input (not in specification format) to disable module's
480
+ builtin textobject in favor of external or Neovim's builtin mapping.
481
+ - Keys should use character representation which can be |getcharstr()| output.
482
+ For example, `'\r'` and not `'<CR>'`.
483
+
484
+ Examples:
485
+ >lua
486
+ require('mini.ai').setup({
487
+ custom_textobjects = {
488
+ -- Tweak argument textobject
489
+ a = require('mini.ai').gen_spec.argument({ brackets = { '%b()' } }),
490
+
491
+ -- Disable brackets alias in favor of builtin block textobject
492
+ b = false,
493
+
494
+ -- Now `vax` should select `xxx` and `vix` - middle `x`
495
+ x = { 'x()x()x' },
496
+
497
+ -- Whole buffer
498
+ g = function()
499
+ local from = { line = 1, col = 1 }
500
+ local to = {
501
+ line = vim.fn.line('$'),
502
+ col = math.max(vim.fn.getline('$'):len(), 1)
503
+ }
504
+ return { from = from, to = to }
505
+ end
506
+ }
507
+ })
508
+
509
+ -- Use `vim.b.miniai_config` to customize per buffer
510
+ -- Example of specification useful for Markdown files:
511
+ local spec_pair = require('mini.ai').gen_spec.pair
512
+ vim.b.miniai_config = {
513
+ custom_textobjects = {
514
+ ['*'] = spec_pair('*', '*', { type = 'greedy' }),
515
+ ['_'] = spec_pair('_', '_', { type = 'greedy' }),
516
+ },
517
+ }
518
+ <
519
+ There are more example specifications in |MiniAi-textobject-specification|.
520
+
521
+ # Search method ~
522
+
523
+ Value of `config.search_method` defines how best match search is done.
524
+ Based on its value, one of the following matches will be selected:
525
+ - Covering match. Left/right edge is before/after left/right edge of
526
+ reference region.
527
+ - Previous match. Left/right edge is before left/right edge of reference
528
+ region.
529
+ - Next match. Left/right edge is after left/right edge of reference region.
530
+ - Nearest match. Whichever is closest among previous and next matches.
531
+
532
+ Possible values are:
533
+ - `'cover'` - use only covering match. Don't use either previous or
534
+ next; report that there is no textobject found.
535
+ - `'cover_or_next'` (default) - use covering match. If not found, use next.
536
+ - `'cover_or_prev'` - use covering match. If not found, use previous.
537
+ - `'cover_or_nearest'` - use covering match. If not found, use nearest.
538
+ - `'next'` - use next match.
539
+ - `'prev'` - use previous match.
540
+ - `'nearest'` - use nearest match.
541
+
542
+ Note: search is first performed on the reference region lines and only
543
+ after failure - on the whole neighborhood defined by `config.n_lines`. This
544
+ means that with `config.search_method` not equal to `'cover'`, "prev" or
545
+ "next" textobject will end up as search result if they are found on first
546
+ stage although covering match might be found in bigger, whole neighborhood.
547
+ This design is based on observation that most of the time operation is done
548
+ within reference region lines (usually cursor line).
549
+
550
+ Here is an example of what `a)` textobject is based on a value of
551
+ `'config.search_method'` when cursor is inside `bbb` word:
552
+ - `'cover'`: `(a) bbb (c)` -> none
553
+ - `'cover_or_next'`: `(a) bbb (c)` -> `(c)`
554
+ - `'cover_or_prev'`: `(a) bbb (c)` -> `(a)`
555
+ - `'cover_or_nearest'`: depends on cursor position.
556
+ For first and second `b` - as in `cover_or_prev` (as previous match is
557
+ nearer), for third - as in `cover_or_next` (as next match is nearer).
558
+ - `'next'`: `(a) bbb (c)` -> `(c)`. Same outcome for `(bbb)`.
559
+ - `'prev'`: `(a) bbb (c)` -> `(a)`. Same outcome for `(bbb)`.
560
+ - `'nearest'`: depends on cursor position (same as in `'cover_or_nearest'`).
561
+
562
+ # Mappings ~
563
+
564
+ Mappings `around_next` / `inside_next` and `around_last` / `inside_last` are
565
+ essentially `around` / `inside` but using search method `'next'` and `'prev'`.
566
+
567
+ ## Overriding default `an` and `in` ~
568
+ *MiniAi-default-an-in*
569
+
570
+ Default `around_next` / `inside_next` mappings override newly added in Neovim=0.12
571
+ built-in mappings |v_an| and |v_in|. This is intentional for better usability
572
+ and backwards compatibility. There are several ways to work around this:
573
+
574
+ - Remap Neovim's `an` / `in` to something else before calling |MiniAi.setup()|: >lua
575
+
576
+ -- Use `<Leader>ls` and `<Leader>lS` for incremental selection
577
+ local copy_keymap = function(mode, from_lhs, to_lhs)
578
+ local keymap = vim.fn.maparg(from_lhs, mode, false, true)
579
+ local rhs = keymap.callback or keymap.rhs
580
+ vim.keymap.set(mode, to_lhs, rhs, { desc = keymap.desc })
581
+ end
582
+ copy_keymap('x', 'an', '<Leader>ls')
583
+ copy_keymap('x', 'in', '<Leader>lS')
584
+
585
+ -- ...
586
+ require('mini.ai').setup({...})
587
+ <
588
+ - Use |MiniAi.gen_spec.treesitter()| with one or many captures for versatile
589
+ tree-sitter based textobjects. It also allows consecutive application in
590
+ Visual mode: similar to incremental selection, with `next` / `last` variants,
591
+ but without "decrease selection".
592
+
593
+ - Use other values for "next" / "last" variants. For example: >lua
594
+
595
+ require('mini.ai').setup({
596
+ mappings = {
597
+ around_next = 'aN',
598
+ inside_next = 'iN',
599
+ around_last = 'aL',
600
+ inside_last = 'iL',
601
+ }
602
+ })
603
+ <
604
+ ## Overriding default `al` and `il` ~
605
+ *MiniAi-default-al-il*
606
+
607
+ Default `around_last` / `inside_last` mappings override newly added in Neovim=0.13
608
+ built-in mappings |al| and |il|. This is intentional for better usability
609
+ and backwards compatibility. There are several ways to work around this:
610
+
611
+ - Use |MiniExtra.gen_ai_spec.buffer()| and |MiniExtra.gen_ai_spec.line()| to
612
+ create custom textobjects for buffer and line: >lua
613
+
614
+ require('mini.extra').setup()
615
+ require('mini.ai').setup({
616
+ custom_textobjects = {
617
+ -- Makes `aB` equivalent to built-in `al`
618
+ B = MiniExtra.gen_ai_spec.buffer(),
619
+ -- Makes `iL` equivalent to built-in `il`
620
+ L = MiniExtra.gen_ai_spec.line(),
621
+ },
622
+ })
623
+ <
624
+ - Use other values for "next" / "last" variants. See |MiniAi-default-an-in|.
625
+
626
+ ------------------------------------------------------------------------------
627
+ *MiniAi.find_textobject()*
628
+ `MiniAi.find_textobject`({ai_type}, {id}, {opts})
629
+ Find textobject region
630
+
631
+ Parameters ~
632
+ {ai_type} `(string)` One of `'a'` or `'i'`.
633
+ {id} `(string)` Single character string representing textobject id. It is
634
+ used to get specification which is later used to compute textobject region.
635
+ Note: if specification is a function, it is called with all present
636
+ arguments (`opts` is populated with default arguments).
637
+ {opts} `(table|nil)` Options. Possible fields:
638
+ - <n_lines> - Number of lines within which textobject is searched.
639
+ Default: `config.n_lines` (see |MiniAi.config|).
640
+ - <n_times> - Number of times to perform a consecutive search. Each one
641
+ is done with reference region being previous found textobject region.
642
+ Default: 1.
643
+ - <reference_region> - region to try to cover (see |MiniAi-glossary|). It
644
+ is guaranteed that output region will not be inside or equal to this one.
645
+ Default: empty region at cursor position.
646
+ - <search_method> - Search method. Default: `config.search_method`.
647
+
648
+ Return ~
649
+ `(table|nil)` Region of textobject or `nil` if no textobject different
650
+ from `opts.reference_region` was consecutively found `opts.n_times` times.
651
+
652
+ ------------------------------------------------------------------------------
653
+ *MiniAi.move_cursor()*
654
+ `MiniAi.move_cursor`({side}, {ai_type}, {id}, {opts})
655
+ Move cursor to edge of textobject
656
+
657
+ Parameters ~
658
+ {side} `(string)` One of `'left'` or `'right'`.
659
+ {ai_type} `(string)` One of `'a'` or `'i'`.
660
+ {id} `(string)` Single character string representing textobject id.
661
+ {opts} `(table|nil)` Same as in |MiniAi.find_textobject()|.
662
+ `opts.n_times` means number of actual jumps (important when cursor
663
+ already on the potential jump spot).
664
+
665
+ ------------------------------------------------------------------------------
666
+ *MiniAi.gen_spec*
667
+ `MiniAi.gen_spec`
668
+ Generate common textobject specifications
669
+
670
+ This is a table with function elements. Call to actually get specification.
671
+
672
+ Example: >lua
673
+
674
+ local gen_spec = require('mini.ai').gen_spec
675
+ require('mini.ai').setup({
676
+ custom_textobjects = {
677
+ -- Tweak argument to be recognized only inside `()` between `;`
678
+ a = gen_spec.argument({ brackets = { '%b()' }, separator = ';' }),
679
+
680
+ -- Tweak function call to not detect dot in function name
681
+ f = gen_spec.function_call({ name_pattern = '[%w_]' }),
682
+
683
+ -- Function definition (needs treesitter queries with these captures)
684
+ F = gen_spec.treesitter({ a = '@function.outer', i = '@function.inner' }),
685
+
686
+ -- Make `|` select both edges in non-balanced way
687
+ ['|'] = gen_spec.pair('|', '|', { type = 'non-balanced' }),
688
+ }
689
+ })
690
+ <
691
+ ------------------------------------------------------------------------------
692
+ *MiniAi.gen_spec.argument()*
693
+ `MiniAi.gen_spec.argument`({opts})
694
+ Argument specification
695
+
696
+ Argument textobject (has default `a` identifier) is a region inside
697
+ balanced bracket between allowed not excluded separators. Use this function
698
+ to tweak how it works.
699
+
700
+ Examples:
701
+ - `argument({ brackets = { '%b()' } })` will search for an argument only
702
+ inside balanced `()`.
703
+ - `argument({ separator = '[,;]' })` will treat both `,` and `;` as separators.
704
+ - `argument({ exclude_regions = { '%b()' } })` will exclude separators
705
+ which are inside balanced `()` (inside outer brackets).
706
+
707
+ Parameters ~
708
+ {opts} `(table|nil)` Options. Allowed fields:
709
+ - <brackets> - array of patterns for outer balanced brackets.
710
+ Default: `{ '%b()', '%b[]', '%b{}' }` (any `()`, `[]`, or `{}` can
711
+ enclose arguments).
712
+ - <separator> - separator pattern. Default: `','`.
713
+ One of the practical usages of this option is to include whitespace
714
+ around character to be a part of separator. For example, `'%s*,%s*'`
715
+ will treat as separator not only `,`, but its possible surrounding
716
+ whitespace. This has both positive and negative effects. On one hand,
717
+ `daa` executed over the first argument will delete whitespace after
718
+ first comma, leading to a more expected outcome. On the other hand it
719
+ is ambiguous which argument is picked when cursor is over whitespace
720
+ near the character separator.
721
+ - <exclude_regions> - array with patterns for regions inside which
722
+ separators will be ignored.
723
+ Default: `{ '%b""', "%b''", '%b()', '%b[]', '%b{}' }` (separators
724
+ inside balanced quotes or brackets are ignored).
725
+
726
+ ------------------------------------------------------------------------------
727
+ *MiniAi.gen_spec.function_call()*
728
+ `MiniAi.gen_spec.function_call`({opts})
729
+ Function call specification
730
+
731
+ Function call textobject (has default `f` identifier) is a region with some
732
+ characters followed by balanced `()`. Use this function to tweak how it works.
733
+
734
+ Example:
735
+ - `function_call({ name_pattern = '[%w_]' })` will recognize function name with
736
+ only alphanumeric or underscore (not dot).
737
+
738
+ Parameters ~
739
+ {opts} `(table|nil)` Options. Allowed fields:
740
+ - <name_pattern> - string pattern of character set allowed in function name.
741
+ Default: `'[%w_%.]'` (alphanumeric, underscore, or dot).
742
+ Note: should be enclosed in `[]`.
743
+
744
+ ------------------------------------------------------------------------------
745
+ *MiniAi.gen_spec.pair()*
746
+ `MiniAi.gen_spec.pair`({left}, {right}, {opts})
747
+ Pair specification
748
+
749
+ Use it to define textobject for region surrounded with `left` from left and
750
+ `right` from right. The `a` textobject includes both edges, `i` - excludes them.
751
+
752
+ Region can be one of several types (controlled with `opts.type`). All
753
+ examples are for default search method, `a` textobject, and use `'_'` as
754
+ both `left` and `right`:
755
+ - Non-balanced (`{ type = 'non-balanced' }`), default. Equivalent to using
756
+ `x.-y` as first pattern. Example: on line `_a_b_c_` it consecutively
757
+ matches `_a_`, `_b_`, `_c_`.
758
+ - Balanced (`{ type = 'balanced' }`). Equivalent to using `%bxy` as first
759
+ pattern. Example: on line `_a_b_c_` it consecutively matches `_a_`, `_c_`.
760
+ Note: both `left` and `right` should be single character.
761
+ - Greedy (`{ type = 'greedy' }`). Like non-balanced but will select maximum
762
+ consecutive `left` and `right` edges. Example: on line `__a__b_` it
763
+ consecutively selects `__a__` and `__b_`. Note: both `left` and `right`
764
+ should be single character.
765
+
766
+ Parameters ~
767
+ {left} `(string)` Left edge.
768
+ {right} `(string)` Right edge.
769
+ {opts} `(table|nil)` Options. Possible fields:
770
+ - <type> - Type of a pair. One of `'non-balanced'` (default), `'balanced'`,
771
+ `'greedy'`.
772
+
773
+ ------------------------------------------------------------------------------
774
+ *MiniAi.gen_spec.treesitter()*
775
+ `MiniAi.gen_spec.treesitter`({ai_captures}, {opts})
776
+ Treesitter specification
777
+
778
+ This is a specification in function form. When called with a pair of
779
+ treesitter captures, it returns a specification function outputting an
780
+ array of regions that match corresponding (`a` or `i`) capture.
781
+
782
+ In order for this to work, apart from working treesitter parser for desired
783
+ language, user should have a reachable language-specific `'textobjects'`
784
+ query (see |vim.treesitter.query.get()|).
785
+ The most straightforward way for this is to have `textobjects.scm` query
786
+ file with treesitter captures stored in some recognized path. This is
787
+ primarily designed to be compatible with plugin
788
+ `nvim-treesitter/nvim-treesitter-textobjects`, but can be used without it.
789
+
790
+ Two most common approaches for having a query file:
791
+ - Install `nvim-treesitter/nvim-treesitter-textobjects`. It has curated and
792
+ well maintained builtin query files for many languages with a standardized
793
+ capture names, like `function.outer`, `function.inner`, etc.
794
+ - Manually create file `after/queries/<language-name>/textobjects.scm` in
795
+ your |$XDG_CONFIG_HOME| directory. It should contain queries with
796
+ captures (later used to define textobjects). See |lua-treesitter-query|.
797
+ To verify that query file is reachable, run (example for "lua" language,
798
+ output should have at least an intended file): >vim
799
+
800
+ :lua print(vim.inspect(vim.treesitter.query.get_files('lua','textobjects')))
801
+ <
802
+ Example configuration for function definition textobject with
803
+ `nvim-treesitter/nvim-treesitter-textobjects` captures:
804
+ >lua
805
+ local spec_treesitter = require('mini.ai').gen_spec.treesitter
806
+ require('mini.ai').setup({
807
+ custom_textobjects = {
808
+ F = spec_treesitter({ a = '@function.outer', i = '@function.inner' }),
809
+ o = spec_treesitter({
810
+ a = { '@conditional.outer', '@loop.outer' },
811
+ i = { '@conditional.inner', '@loop.inner' },
812
+ })
813
+ }
814
+ })
815
+ <
816
+ Notes:
817
+ - Be sure that query files don't contain unknown |treesitter-directives|
818
+ (like `#make-range!`, for example). Otherwise textobject for such capture
819
+ might not be found as |lua-treesitter-core| won't treat them as captures.
820
+ Verify with `:=vim.treesitter.query.get('lang', 'textobjects')` and see
821
+ if the target capture is recognized as one.
822
+ - It uses buffer's |filetype| to determine query language.
823
+ - It first searches the language under cursor for matches. If no matches are
824
+ found, it falls back to searching parent languages (up to the buffer's root
825
+ language). If no matches are found again, it falls back to recursively
826
+ searching all children languages (from the language under cursor). If no
827
+ matches again - report no matches.
828
+ - On large files it is slower than pattern-based textobjects. Still very
829
+ fast though (one search should be magnitude of milliseconds or tens of
830
+ milliseconds on really large file).
831
+
832
+ Parameters ~
833
+ {ai_captures} `(table)` Captures for `a` and `i` textobjects: table with
834
+ <a> and <i> fields with captures for `a` and `i` textobjects respectively.
835
+ Each value can be either a string capture (should start with `'@'`) or an
836
+ array of such captures (best among all matches will be chosen).
837
+ {opts} `(table|nil)` Options. Possible values:
838
+ - <use_nvim_treesitter> - whether to try to use `nvim-treesitter` plugin
839
+ (if present) to do the query. It used to implement more advanced behavior
840
+ and more coherent experience if `nvim-treesitter-textobjects` queries are
841
+ used. However, as |lua-treesitter-core| methods are more capable now,
842
+ the option will soon be removed. Only present for backward compatibility.
843
+ Default: `false`.
844
+
845
+ Return ~
846
+ `(function)` Function with |MiniAi.find_textobject()| signature which
847
+ returns array of current buffer regions representing matches for
848
+ corresponding (`a` or `i`) treesitter capture.
849
+
850
+ See also ~
851
+ - |MiniAi-textobject-specification| for how this type of textobject
852
+ specification is processed.
853
+ - |vim.treesitter.query.get()| for how query is fetched.
854
+ - |Query:iter_captures()| for how all query captures are iterated in case of
855
+ no `nvim-treesitter`.
856
+
857
+ ------------------------------------------------------------------------------
858
+ *MiniAi.gen_spec.user_prompt()*
859
+ `MiniAi.gen_spec.user_prompt`()
860
+ Specification from user prompt
861
+
862
+ - Ask user for left and right textobject edges as raw strings (no pattern).
863
+ It uses |MiniInput.get()| (if enabled) or |input().
864
+ - Construct specification for a textobject that matches from left edge string
865
+ to right edge string: `a` includes both strings, `i` only insides.
866
+
867
+ Used for |MiniAi-builtin-textobjects| with identifier `?`.
868
+
869
+ Return ~
870
+ `(function)` Textobject specification as function.
871
+
872
+ ------------------------------------------------------------------------------
873
+ *MiniAi.select_textobject()*
874
+ `MiniAi.select_textobject`({ai_type}, {id}, {opts})
875
+ Visually select textobject region
876
+
877
+ Does nothing if no region is found.
878
+
879
+ Parameters ~
880
+ {ai_type} `(string)` One of `'a'` or `'i'`.
881
+ {id} `(string)` Single character string representing textobject id.
882
+ {opts} `(table|nil)` Same as in |MiniAi.find_textobject()|. Extra fields:
883
+ - <vis_mode> - One of `'v'`, `'V'`, or `'\22'` (escaped version of `'<C-v>'`).
884
+ Default: Latest visual mode.
885
+ - <operator_pending> - Whether selection is for Operator-pending mode.
886
+ Used in that mode's mappings, shouldn't be used directly. Default: `false`.
887
+
888
+
889
+ vim:tw=78:ts=8:noet:ft=help:norl: