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,923 @@
1
+ *mini.align* Align text interactively
2
+
3
+ MIT License Copyright (c) 2022 Evgeni Chasnovski
4
+
5
+ ------------------------------------------------------------------------------
6
+ *MiniAlign*
7
+ Rich and flexible customization of both alignment rules and user interaction.
8
+ Works with charwise, linewise, and blockwise selections in both Normal mode
9
+ (on textobject/motion; with dot-repeat) and Visual mode.
10
+
11
+ Features:
12
+ - Alignment is done in three main steps:
13
+ - <Split> lines into parts based on Lua pattern(s) or user-supplied rule.
14
+ - <Justify> parts for certain side(s) to be same width inside columns.
15
+ - <Merge> parts to be lines, with customizable delimiter(s).
16
+
17
+ Each main step can be preceded by other steps (pre-steps) to achieve
18
+ highly customizable outcome. See `steps` value in |MiniAlign.config|.
19
+ For more details, see |MiniAlign-glossary| and |MiniAlign-algorithm|.
20
+
21
+ - User can control alignment interactively by pressing customizable modifiers
22
+ (single keys representing how alignment steps and/or options should change).
23
+ Some of default modifiers:
24
+ - Press `s` to enter split Lua pattern.
25
+ - Press `j` to choose justification side from available ones ("left",
26
+ "center", "right", "none").
27
+ - Press `m` to enter merge delimiter.
28
+ - Press `f` to enter filter Lua expression to configure which parts
29
+ will be affected (like "align only first column").
30
+ - Press `i` to ignore some commonly unwanted split matches.
31
+ - Press `p` to pair neighboring parts so they be aligned together.
32
+ - Press `t` to trim whitespace from parts.
33
+ - Press `<BS>` (backspace) to delete some last pre-step.
34
+
35
+ For more details, see |MiniAlign-modifiers-builtin| and |MiniAlign-examples|.
36
+
37
+ - Alignment can be done with instant preview (result is updated after each
38
+ modifier) or without it (result is shown and accepted after non-default
39
+ split pattern is set).
40
+
41
+ - Every user interaction is accompanied with helper status message showing
42
+ relevant information about current alignment process.
43
+
44
+ # Setup ~
45
+
46
+ This module needs a setup with `require('mini.align').setup({})` (replace
47
+ `{}` with your `config` table). It will create global Lua table `MiniAlign`
48
+ which you can use for scripting or manually (with `:lua MiniAlign.*`).
49
+
50
+ See |MiniAlign.config| for available config settings.
51
+
52
+ You can override runtime config settings (like `config.modifiers`) locally
53
+ to buffer inside `vim.b.minialign_config` which should have same structure
54
+ as `MiniAlign.config`. See |mini.nvim-buffer-local-config| for more details.
55
+
56
+ To stop module from showing non-error feedback, set `config.silent = true`.
57
+
58
+ # Comparisons ~
59
+
60
+ - [junegunn/vim-easy-align](https://github.com/junegunn/vim-easy-align):
61
+ - |mini.align| is mostly designed after `junegunn/vim-easy-align`, so
62
+ there are a lot of similarities.
63
+ - Both plugins allow users to change alignment options interactively by
64
+ pressing modifier keys (albeit completely different default ones).
65
+ `junegunn/vim-easy-align` has those modifiers fixed, while |mini.align|
66
+ allows their full customization. See |MiniAlign.config| for examples.
67
+ - `junegunn/vim-easy-align` is designed to treat delimiters differently
68
+ than other parts of strings. |mini.align| doesn't distinguish split
69
+ parts from one another by design: splitting is allowed to be done
70
+ based on some other logic than by splitting on delimiters.
71
+ - `junegunn/vim-easy-align` initially aligns by only first delimiter.
72
+ |mini.align| initially aligns by all delimiter.
73
+ - `junegunn/vim-easy-align` implements special filtering by delimiter
74
+ row number. |mini.align| has builtin filtering based on Lua code
75
+ supplied by user in modifier phase. See |MiniAlign.gen_step.filter()|
76
+ and `f` builtin modifier.
77
+ - |mini.align| treats any non-registered modifier as a plain delimiter
78
+ pattern, while `junegunn/vim-easy-align` does not.
79
+ - |mini.align| exports core Lua function used for aligning strings
80
+ (|MiniAlign.align_strings()|).
81
+ - [godlygeek/tabular](https://github.com/godlygeek/tabular):
82
+ - `godlygeek/tabular` is mostly designed around single command which is
83
+ customized by printing its parameters. |mini.align| implements
84
+ different concept of interactive alignment through pressing
85
+ customizable single character modifiers.
86
+ - `godlygeek/tabular` can detect region upon which alignment can be
87
+ desirable. |mini.align| does not by design: use Visual selection or
88
+ textobject/motion to explicitly define region to align.
89
+
90
+ # Disabling ~
91
+
92
+ To disable, set `vim.g.minialign_disable` (globally) or `vim.b.minialign_disable`
93
+ (for a buffer) to `true`. Considering high number of different scenarios
94
+ and customization intentions, writing exact rules for disabling module's
95
+ functionality is left to user. See |mini.nvim-disabling-recipes| for common
96
+ recipes.
97
+
98
+ ------------------------------------------------------------------------------
99
+ *MiniAlign-glossary*
100
+ PARTS ~
101
+ 2d array of strings (array of arrays of strings).
102
+ See more in |MiniAlign.as_parts()|.
103
+
104
+ ROW ~
105
+ First-level array of parts (like `parts[1]`).
106
+
107
+ COLUMN ~
108
+ Array of strings, constructed from parts elements with the same
109
+ second-level index (like `{ parts[1][1],` `parts[2][1], ... }`).
110
+
111
+ STEP ~
112
+ A named callable. See |MiniAlign.new_step()|. When used in terms of alignment
113
+ steps, callable takes two arguments: some object (parts or string array)
114
+ and option table.
115
+
116
+ SPLIT ~
117
+ Process of taking array of strings and converting it into parts.
118
+
119
+ JUSTIFY ~
120
+ Process of taking parts and converting them to aligned parts (all elements
121
+ have same widths inside columns).
122
+
123
+ MERGE ~
124
+ Process of taking parts and converting it back to array of strings. Usually
125
+ by concatenating rows into strings.
126
+
127
+ REGION ~
128
+ Table representing region in a buffer. Fields <from> / <to> have inclusive
129
+ start / end positions (<to> might be `nil` to describe empty region).
130
+ Positions are also tables with <line> and <col> fields (both start at 1).
131
+
132
+ MODE ~
133
+ Either charwise ("char", `v`, |charwise|), linewise ("line", `V`, |linewise|)
134
+ or blockwise ("block", `<C-v>`, |blockwise-visual|)
135
+
136
+ ------------------------------------------------------------------------------
137
+ *MiniAlign-algorithm*
138
+ There are two main processes implemented in |mini.align|: strings alignment
139
+ and interactive region alignment. See |MiniAlign-glossary| for more information
140
+ about used terms.
141
+
142
+ # Strings alignment ~
143
+
144
+ Main implementation is in |MiniAlign.align_strings()|. Its input is array of
145
+ strings and output - array of aligned strings. The process consists from three
146
+ main steps (split, justify, merge) which can be preceded by any number of
147
+ preliminary steps (pre-split, pre-justify, pre-merge).
148
+
149
+ Algorithm:
150
+ - <Pre-split>. Take input array of strings and consecutively apply all
151
+ pre-split steps (`steps.pre_split`). Each one has `(strings, opts)` signature
152
+ and should modify array in place.
153
+ - <Split>. Take array of strings and convert it to parts with `steps.split()`.
154
+ It has `(strings, opts)` signature and should return parts.
155
+ - <Pre-justify>. Take parts and consecutively apply all pre-justify
156
+ steps (`steps.pre_justify`). Each one has `(parts, opts)` signature and
157
+ should modify parts in place.
158
+ - <Justify>. Take parts and apply `steps.justify()`. It has `(parts, opts)`
159
+ signature and should modify parts in place.
160
+ - <Pre-merge>. Take parts and consecutively apply all pre-merge
161
+ steps (`steps.pre_merge`). Each one has `(parts, opts)` signature and
162
+ should modify parts in place.
163
+ - <Merge>. Take parts and convert it to array of strings with `steps.merge()`.
164
+ It has `(parts, opts)` signature and should return array of strings.
165
+
166
+ Notes:
167
+ - All table objects are initially copied so that modification in place doesn't
168
+ affect workflow.
169
+ - Default main steps are designed to be controlled via options. See
170
+ |MiniAlign.align_strings()| and default step entries in |MiniAlign.gen_step|.
171
+ - All steps are guaranteed to take same option table as second argument.
172
+ This allows steps to "talk" to each other, i.e. earlier steps can pass data
173
+ to later ones.
174
+
175
+ # Interactive region alignment ~
176
+
177
+ Interactive alignment is a main entry point for most users. It can be done
178
+ in two flavors:
179
+ - <Without-preview>. Initiated via mapping defined in `start` of
180
+ `MiniAlign.config.mappings`. Alignment is accepted once split pattern becomes
181
+ non-default.
182
+ - <With-preview>. Initiated via mapping defined in `start_with_preview` of
183
+ `MiniAlign.config.mappings`. Alignment result is shown after every modifier
184
+ and is accepted after `<CR>` (`Enter`) is hit. Note: each preview is done by
185
+ applying current alignment steps and options to the initial region lines,
186
+ not the ones currently displaying in preview.
187
+
188
+ Lifecycle (assuming default mappings):
189
+ - <Initiate-alignment>:
190
+ - In Normal mode type `ga` (or `gA` to show preview) followed by textobject
191
+ or motion defining region to be aligned.
192
+ - In Visual mode select region and type `ga` (or `gA` to show preview).
193
+ Strings contained in selected region will be used as input to
194
+ |MiniAlign.align_strings()|.
195
+ Beware of mode when selecting region: charwise (`v`), linewise (`V`), or
196
+ blockwise (`<C-v>`). They all behave differently.
197
+ - <Press-modifiers>. Press single keys one at a time:
198
+ - If pressed key is among table keys of `modifiers` table of
199
+ |MiniAlign.config|, its function value is executed. It usually modifies
200
+ some options(s) and/or affects some pre-step(s).
201
+ - If pressed key is not among defined modifiers, it is treated as plain
202
+ split pattern.
203
+ This process can either end by itself (usually in case of no preview and
204
+ non-default split pattern being set) or you can choose to end it manually.
205
+ - <Accept-or-discard>. In case of active preview, accept current result by
206
+ pressing `<CR>`. Discard any result and return to initial regions with
207
+ either `<Esc>` or `<C-c>`.
208
+
209
+ See more in |MiniAlign-modifiers-builtin| and |MiniAlign-examples|.
210
+
211
+ Notes:
212
+ - Visual blockwise selection works best with |'virtualedit'| equal to "block"
213
+ or "all".
214
+ - Alignment with preview works best with |'showmode'| disabled.
215
+
216
+ ------------------------------------------------------------------------------
217
+ *MiniAlign-modifiers-builtin*
218
+ Overview of builtin modifiers
219
+
220
+ All examples assume interactive alignment with preview in linewise mode. With
221
+ default mappings, use `V` to select lines and `gA` to initiate alignment. It
222
+ might be helpful to copy lines into modifiable buffer and experiment yourself.
223
+
224
+ Notes:
225
+ - Any pressed key which doesn't have defined modifier will be treated as
226
+ plain split pattern.
227
+ - All modifiers can be customized inside |MiniAlign.setup()|. See "Modifiers"
228
+ section of |MiniAlign.config|.
229
+
230
+ # Main option modifiers ~
231
+
232
+ <s> Enter split pattern (confirm prompt by pressing `<CR>`). Input is treated
233
+ as plain delimiter.
234
+
235
+ Before: >
236
+ a-b-c
237
+ aa-bb-cc
238
+ <
239
+ After typing `s-<CR>`: >
240
+ a -b -c
241
+ aa-bb-cc
242
+ <
243
+ <j> Choose justify side. Prompts user (with helper message) to type single
244
+ character identifier of side: `l`eft, `c`enter, `r`ight, `n`one.
245
+
246
+ Before: >
247
+ a_b_c
248
+ aa_bb_cc
249
+ <
250
+ After typing `_jr` (first make split by `_`): >
251
+ a_ b_ c
252
+ aa_bb_cc
253
+ <
254
+ <m> Enter merge delimiter (confirm prompt by pressing `<CR>`).
255
+
256
+ Before: >
257
+ a_b_c
258
+ aa_bb_cc
259
+ <
260
+ After typing `_m--<CR>` (first make split by `_`): >
261
+ a --_--b --_--c
262
+ aa--_--bb--_--cc
263
+ <
264
+ # Modifiers adding pre-steps ~
265
+
266
+ <f> Enter filter expression. See more details in |MiniAlign.gen_step.filter()|.
267
+
268
+ Before: >
269
+ a_b_c
270
+ aa_bb_cc
271
+ <
272
+ After typing `_fn==1<CR>` (first make split by `_`): >
273
+ a _b_c
274
+ aa_bb_cc
275
+ <
276
+ <i> Ignore some split matches. It modifies `split_exclude_patterns` option by
277
+ adding commonly wanted patterns. See more details in
278
+ |MiniAlign.gen_step.ignore_split()|.
279
+
280
+ Before: >
281
+ /* This_is_assumed_to_be_comment */
282
+ a"_"_b
283
+ aa_bb
284
+ <
285
+ After typing `_i` (first make split by `_`): >
286
+ /* This_is_assumed_to_be_comment */
287
+ a"_"_b
288
+ aa _bb
289
+ <
290
+ <p> Pair neighboring parts.
291
+
292
+ Before: >
293
+ a_b_c
294
+ aaa_bbb_ccc
295
+ <
296
+ After typing `_p` (first make split by `_`): >
297
+ a_ b_ c
298
+ aaa_bbb_ccc
299
+ <
300
+ <t> Trim parts from whitespace on both sides (keeping indentation).
301
+
302
+ Before: >
303
+ a _ b _ c
304
+ aa _bb _cc
305
+ <
306
+ After typing `_t` (first make split by `_`): >
307
+ a _b _c
308
+ aa_bb_cc
309
+ <
310
+ # Delete some last pre-step ~
311
+
312
+ <BS> Delete one of the pre-steps. If there is only one kind of pre-steps,
313
+ remove its latest added one. If not, prompt user to choose pre-step kind
314
+ by entering single character: `s`plit, `j`ustify, `m`erge.
315
+
316
+ Examples:
317
+ - `tp<BS>` results in only "trim" step to be left.
318
+ - `it<BS>` prompts to choose which step to delete (pre-split or
319
+ pre-justify in this case).
320
+
321
+ # Special configurations for common splits ~
322
+
323
+ <=> Use special pattern to align by a group of consecutive "=". It can be
324
+ preceded by any number of punctuation marks and followed by some sommon
325
+ punctuation characters. Trim whitespace and merge with single space.
326
+
327
+ Before: >
328
+ a=b
329
+ aa<=bb
330
+ aaa===bbb
331
+ aaaa = cccc
332
+ <
333
+ After typing `=`: >
334
+ a = b
335
+ aa <= bb
336
+ aaa === bbb
337
+ aaaa = cccc
338
+ <
339
+ <,> Besides splitting by "," character, trim whitespace, pair neighboring
340
+ parts and merge with single space.
341
+
342
+ Before: >
343
+ a,b
344
+ aa,bb
345
+ aaa , bbb
346
+ <
347
+ After typing `,`: >
348
+ a, b
349
+ aa, bb
350
+ aaa, bbb
351
+ <
352
+ <|> Split by "|" character, trim whitespace, merge with single space.
353
+
354
+ Before: >
355
+ |a|b|
356
+ |aa|bb|
357
+ |aaa | bbb |
358
+ <
359
+ After typing `|`: >
360
+ | a | b |
361
+ | aa | bb |
362
+ | aaa | bbb |
363
+ <
364
+ <Space> (Space bar) Squash consecutive whitespace into single space (except
365
+ possible indentation) and split by `%s+` pattern (keeps indentation).
366
+
367
+ Before: >
368
+ a b c
369
+ aa bb cc
370
+ <
371
+ After typing `<Space>`: >
372
+ a b c
373
+ aa bb cc
374
+ <
375
+ ------------------------------------------------------------------------------
376
+ *MiniAlign-examples*
377
+ Copy lines in modifiable buffer, initiate alignment with preview (`gAip`)
378
+ and try typing suggested key sequences.
379
+ These are modified examples taken from `junegunn/vim-easy-align`.
380
+
381
+ # Equal sign ~
382
+
383
+ Lines: >
384
+
385
+ # This=is=assumed=to be a comment
386
+ "a ="
387
+ a =
388
+ a = 1
389
+ bbbb = 2
390
+ ccccccc = 3
391
+ ccccccccccccccc
392
+ ddd = 4
393
+ eeee === eee = eee = eee=f
394
+ fff = ggg += gg &&= gg
395
+ g != hhhhhhhh == 888
396
+ i := 5
397
+ i %= 5
398
+ i *= 5
399
+ j =~ 5
400
+ j >= 5
401
+ aa => 123
402
+ aa <<= 123
403
+ aa >>= 123
404
+ bbb => 123
405
+ c => 1233123
406
+ d => 123
407
+ dddddd &&= 123
408
+ dddddd ||= 123
409
+ dddddd /= 123
410
+ gg <=> ee
411
+ <
412
+ Key sequences:
413
+ - `=`
414
+ - `=jc`
415
+ - `=jr`
416
+ - `=m!<CR>`
417
+ - `=p`
418
+ - `=i` (execute `:lua vim.o.commentstring = '# %s'` for full experience)
419
+ - `=<BS>`
420
+ - `=<BS>p`
421
+ - `=fn==1<CR>`
422
+ - `=<BS>fn==1<CR>t`
423
+ - `=frow>7<CR>`
424
+
425
+ ------------------------------------------------------------------------------
426
+ *MiniAlign.setup()*
427
+ `MiniAlign.setup`({config})
428
+ Module setup
429
+
430
+ Parameters ~
431
+ {config} `(table|nil)` Module config table. See |MiniAlign.config|.
432
+
433
+ Usage ~
434
+ >lua
435
+ require('mini.align').setup() -- use default config
436
+ -- OR
437
+ require('mini.align').setup({}) -- replace {} with your config table
438
+ <
439
+ ------------------------------------------------------------------------------
440
+ *MiniAlign.config*
441
+ `MiniAlign.config`
442
+ Defaults ~
443
+ >lua
444
+ MiniAlign.config = {
445
+ -- Module mappings. Use `''` (empty string) to disable one.
446
+ mappings = {
447
+ start = 'ga',
448
+ start_with_preview = 'gA',
449
+ },
450
+
451
+ -- Modifiers changing alignment steps and/or options
452
+ modifiers = {
453
+ -- Main option modifiers
454
+ ['s'] = --<function: enter split pattern>,
455
+ ['j'] = --<function: choose justify side>,
456
+ ['m'] = --<function: enter merge delimiter>,
457
+
458
+ -- Modifiers adding pre-steps
459
+ ['f'] = --<function: filter parts by entering Lua expression>,
460
+ ['i'] = --<function: ignore some split matches>,
461
+ ['p'] = --<function: pair parts>,
462
+ ['t'] = --<function: trim parts>,
463
+
464
+ -- Delete some last pre-step
465
+ ['<BS>'] = --<function: delete some last pre-step>,
466
+
467
+ -- Special configurations for common splits
468
+ ['='] = --<function: enhanced setup for '='>,
469
+ [','] = --<function: enhanced setup for ','>,
470
+ ['|'] = --<function: enhanced setup for '|'>,
471
+ [' '] = --<function: enhanced setup for ' '>,
472
+ },
473
+
474
+ -- Default options controlling alignment process
475
+ options = {
476
+ split_pattern = '',
477
+ justify_side = 'left',
478
+ merge_delimiter = '',
479
+ },
480
+
481
+ -- Default steps performing alignment (if `nil`, default is used)
482
+ steps = {
483
+ pre_split = {},
484
+ split = nil,
485
+ pre_justify = {},
486
+ justify = nil,
487
+ pre_merge = {},
488
+ merge = nil,
489
+ },
490
+
491
+ -- Whether to disable showing non-error feedback
492
+ -- This also affects (purely informational) helper messages shown after
493
+ -- idle time if user input is required.
494
+ silent = false,
495
+ }
496
+ <
497
+ # Modifiers ~
498
+
499
+ `MiniAlign.config.modifiers` is used to define interactive user experience
500
+ of managing alignment process. It is a table with single character keys and
501
+ modifier function values.
502
+
503
+ Each modifier function:
504
+ - Is called when corresponding modifier key is pressed.
505
+ - Has signature `(steps, opts)` and should modify any of its input in place.
506
+
507
+ Examples:
508
+ - Modifier function used for default `i` modifier: >lua
509
+
510
+ function(steps, _)
511
+ table.insert(steps.pre_split, MiniAlign.gen_step.ignore_split())
512
+ end
513
+ <
514
+ - Tweak `t` modifier to use highest indentation instead of keeping it: >lua
515
+
516
+ require('mini.align').setup({
517
+ modifiers = {
518
+ t = function(steps, _)
519
+ local trim_high = MiniAlign.gen_step.trim('both', 'high')
520
+ table.insert(steps.pre_justify, trim_high)
521
+ end
522
+ }
523
+ })
524
+ <
525
+ - Tweak `j` modifier to cycle through available "justify_side" option
526
+ values (like in `junegunn/vim-easy-align`): >lua
527
+
528
+ require('mini.align').setup({
529
+ modifiers = {
530
+ j = function(_, opts)
531
+ local next_option = ({
532
+ left = 'center', center = 'right', right = 'none', none = 'left',
533
+ })[opts.justify_side]
534
+ opts.justify_side = next_option or 'left'
535
+ end,
536
+ },
537
+ })
538
+ <
539
+ # Options ~
540
+
541
+ `MiniAlign.config.options` defines default values of options used to control
542
+ behavior of steps.
543
+
544
+ Examples:
545
+ - Set `justify_side = 'center'` to center align at initialization.
546
+
547
+ For more details about options see |MiniAlign.align_strings()| and entries of
548
+ |MiniAlign.gen_step| for default main steps.
549
+
550
+ # Steps ~
551
+
552
+ `MiniAlign.config.steps` defines default steps to be applied during
553
+ alignment process.
554
+
555
+ Examples:
556
+ - Align by default only first pair of columns: >lua
557
+
558
+ local align = require('mini.align')
559
+ align.setup({
560
+ steps = {
561
+ pre_justify = { align.gen_step.filter('n == 1') }
562
+ },
563
+ })
564
+ <
565
+ ------------------------------------------------------------------------------
566
+ *MiniAlign.align_strings()*
567
+ `MiniAlign.align_strings`({strings}, {opts}, {steps})
568
+ Align strings
569
+
570
+ For details about alignment process see |MiniAlign-algorithm|.
571
+
572
+ Parameters ~
573
+ {strings} `(table)` Array of strings.
574
+ {opts} `(table|nil)` Options. Its copy will be passed to steps as second
575
+ argument. Extended with `MiniAlign.config.options`.
576
+ This is a place to control default main steps:
577
+ - `opts.split_pattern` - Lua pattern(s) used to make split parts.
578
+ - `opts.split_exclude_patterns` - which split matches should be ignored.
579
+ - `opts.justify_side` - which direction(s) alignment should be done.
580
+ - `opts.justify_offsets` - offsets tweaking width of first column
581
+ - `opts.merge_delimiter` - which delimiter(s) to use when merging.
582
+ For more information see |MiniAlign.gen_step| entry for corresponding
583
+ default step.
584
+ {steps} `(table|nil)` Steps. Extended with `MiniAlign.config.steps`.
585
+ Possible `nil` values are replaced with corresponding default steps:
586
+ - `split` - |MiniAlign.gen_step.default_split()|.
587
+ - `justify` - |MiniAlign.gen_step.default_justify()|.
588
+ - `merge` - |MiniAlign.gen_step.default_merge()|.
589
+
590
+ ------------------------------------------------------------------------------
591
+ *MiniAlign.align_user()*
592
+ `MiniAlign.align_user`({mode})
593
+ Align current region with user-supplied steps
594
+
595
+ Mostly designed to be used inside mappings.
596
+
597
+ Will use |MiniAlign.align_strings()| and set the following options in `opts`:
598
+ - `justify_offsets` - array of offsets used to achieve actual alignment of
599
+ a region. It is non-trivial (not array of zeros) only for charwise
600
+ selection: offset of first string is computed as width of prefix to the
601
+ left of region start.
602
+ - `region` - current affected region (see |MiniAlign-glossary|). Can be
603
+ used to create more advanced steps.
604
+ - `mode` - mode of selection (see |MiniAlign-glossary|).
605
+
606
+ Parameters ~
607
+ {mode} `(string)` Selection mode. One of "char", "line", "block".
608
+
609
+ ------------------------------------------------------------------------------
610
+ *MiniAlign.as_parts()*
611
+ `MiniAlign.as_parts`({arr2d})
612
+ Convert 2d array of strings to parts
613
+
614
+ This function verifies if input is a proper 2d array of strings and adds
615
+ methods to its copy.
616
+
617
+ Class ~
618
+ {parts}
619
+
620
+ Fields ~
621
+ {apply} `(function)` Takes callable `f` and applies it to every part.
622
+ Callable should have signature `(s, data)`: `s` is a string part,
623
+ `data` - table with its data (<row> has row number, <col> has column number).
624
+ Returns new 2d array.
625
+
626
+ {apply_inplace} `(function)` Takes callable `f` and applies it to every part.
627
+ Should have same signature as in `apply` method. Outputs (should all be
628
+ strings) are assigned in place to a corresponding parts element. Returns
629
+ parts itself to enable method chaining.
630
+
631
+ {get_dims} `(function)` Return dimensions of parts array: a table with
632
+ <row> and <col> keys having number of rows and number of columns (maximum
633
+ number of elements across all rows).
634
+
635
+ {group} `(function)` Concatenate neighboring strings based on supplied
636
+ boolean mask and direction (one of "left", default, or "right"). Has
637
+ signature `(mask, direction)` and modifies parts in place. Returns parts
638
+ itself to enable method chaining.
639
+ Example:
640
+ - Parts: `{ { "a", "b", "c" }, { "d", "e" }, { "f" } }`
641
+ - Mask: `{ { false, false, true }, { true, false }, { false } }`
642
+ - Result for direction "left": `{ { "abc" }, { "d", "e" }, { "f" } }`
643
+ - Result for direction "right": `{ { "ab","c" }, { "de" }, { "f" } }`
644
+
645
+ {pair} `(function)` Concatenate neighboring element pairs. Takes
646
+ `direction` as input (one of "left", default, or "right") and applies
647
+ `group()` for an alternating mask.
648
+ Example:
649
+ - Parts: `{ { "a", "b", "c" }, { "d", "e" }, { "f" } }`
650
+ - Result for direction "left": `{ { "ab", "c" }, { "de" }, { "f" } }`
651
+ - Result for direction "right": `{ { "a", "bc" }, { "de" }, { "f" } }`
652
+
653
+ {slice_col} `(function)` Return column with input index `j`. Note: it might
654
+ not be an array if rows have unequal number of columns.
655
+
656
+ {slice_row} `(function)` Return row with input index `i`.
657
+
658
+ {trim} `(function)` Trim elements whitespace. Has signature `(direction, indent)`
659
+ and modifies parts in place. Returns parts itself to enable method chaining.
660
+ - Possible values of `direction`: "both" (default), "left", "right",
661
+ "none". Defines from which side whitespaces should be removed.
662
+ - Possible values of `indent`: "keep" (default), "low", "high", "remove".
663
+ Defines what to do with possible indent (left whitespace of first string
664
+ in a row). Value "keep" keeps it; "low" makes all indent equal to the
665
+ lowest across rows; "high" - highest across rows; "remove" - removes indent.
666
+
667
+ Usage ~
668
+ >lua
669
+ parts = MiniAlign.as_parts({ { 'a', 'b' }, { 'c' } })
670
+ print(vim.inspect(parts.get_dims())) -- Should be { row = 2, col = 2 }
671
+
672
+ parts.apply_inplace(function(s, data)
673
+ return ' ' .. data.row .. s .. data.col .. ' '
674
+ end)
675
+ print(vim.inspect(parts)) -- Should be { { ' 1a1 ', ' 1b2 ' }, { ' 2c1 ' } }
676
+
677
+ parts.trim('both', 'remove').pair()
678
+ print(vim.inspect(parts)) -- Should be { { '1a11b2' }, { '2c1' } }
679
+ <
680
+ ------------------------------------------------------------------------------
681
+ *MiniAlign.new_step()*
682
+ `MiniAlign.new_step`({name}, {action})
683
+ Create step
684
+
685
+ A step is basically a named callable object. Having a name bundled with
686
+ some action powers helper status message during interactive alignment process.
687
+
688
+ Parameters ~
689
+ {name} `(string)` Step name.
690
+ {action} `(function|table)` Step action. Should be a callable object
691
+ (see |vim.is_callable()|).
692
+
693
+ Return ~
694
+ `(table)` A table with keys: <name> with `name` argument, <action> with `action`.
695
+
696
+ ------------------------------------------------------------------------------
697
+ *MiniAlign.gen_step*
698
+ `MiniAlign.gen_step`
699
+ Generate common action steps
700
+
701
+ This is a table with function elements. Call to actually get step.
702
+
703
+ Each step action is a function that has signature `(object, opts)`, where
704
+ `object` is either parts or array of strings (depends on which stage of
705
+ alignment process it is assumed to be applied) and `opts` is table of options.
706
+
707
+ Outputs of elements named `default_*` are used as default corresponding main
708
+ step (split, justify, merge). Behavior of all of them depend on values from
709
+ supplied options (second argument).
710
+
711
+ Outputs of other elements depend on both step generator input values and
712
+ options supplied at execution. This design is mostly because their output
713
+ can be used several times in pre-steps.
714
+
715
+ Usage ~
716
+ >lua
717
+ local align = require('mini.align')
718
+ align.setup({
719
+ modifiers = {
720
+ -- Use 'T' modifier to remove both whitespace and indent
721
+ T = function(steps, _)
722
+ table.insert(steps.pre_justify, align.gen_step.trim('both', 'remove'))
723
+ end,
724
+ },
725
+ options = {
726
+ -- By default align "right", "left", "right", "left", ...
727
+ justify_side = { 'right', 'left' },
728
+ },
729
+ steps = {
730
+ -- Align by default only first pair of columns
731
+ pre_justify = { align.gen_step.filter('n == 1') },
732
+ },
733
+ })
734
+ <
735
+ ------------------------------------------------------------------------------
736
+ *MiniAlign.gen_step.default_split()*
737
+ `MiniAlign.gen_step.default_split`()
738
+ Generate default split step
739
+
740
+ Output splits strings using matches of Lua pattern(s) from `split_pattern`
741
+ option which are not dismissed by `split_exclude_patterns` option.
742
+
743
+ Outline of how single string is split:
744
+ - Convert `split_pattern` option to array of strings (string is converted
745
+ as one-element array). This array will be recycled in case there are more
746
+ split matches than in converted `split_pattern` array (which almost always).
747
+ - Find all forbidden spans (intervals inside string) - all matches of all
748
+ patterns in `split_exclude_patterns`.
749
+ - Find match for the next pattern. If it is not inside any forbidden span,
750
+ add preceding unmatched substring and matched split as two parts. Repeat
751
+ with the next pattern.
752
+ - If no pattern match is found, add the rest of string as final part.
753
+
754
+ Output uses following options (as part second argument, `opts` table):
755
+ - <split_pattern> - string or array of strings used to detect split matches
756
+ and create parts. Default: `''` meaning no matches (whole string is used
757
+ as part). Examples: `'%s+'`, `{ '<', '>' }`.
758
+ - <split_exclude_patterns> - array of strings defining which regions to
759
+ exclude from being matched. Default: `{}`. Examples: `{ '".-"', '^%s*#.*' }`.
760
+
761
+ Return ~
762
+ `(table)` A step named "split" and with appropriate callable action.
763
+
764
+ See also ~
765
+ |MiniAlign.gen_step.ignore_split()| heavily uses `split_exclude_patterns`.
766
+
767
+ ------------------------------------------------------------------------------
768
+ *MiniAlign.gen_step.default_justify()*
769
+ `MiniAlign.gen_step.default_justify`()
770
+ Generate default justify step
771
+
772
+ Output makes column elements of string parts have equal width by adding
773
+ left and/or right whitespace padding. Which side(s) to pad is defined by
774
+ `justify_side` option. Width of first column can be tweaked with `justify_offsets`
775
+ option.
776
+
777
+ Outline of how parts are justified:
778
+ - Convert `justify_side` option to array of strings (single string is
779
+ converted as one-element array). Recycle this array to have length equal
780
+ to number of columns in parts.
781
+ - For all columns compute maximum width of strings from it (add offsets from
782
+ `justify_offsets` to first column widths). Note: for left alignment, width
783
+ of last row element does not affect column width. This is mainly because
784
+ it won't be padded and helps dealing with "no single match" lines.
785
+ - Make all elements have same width inside column by adding appropriate
786
+ amount of whitespace. Which side(s) to add is controlled by the corresponding
787
+ `justify_side` array element. Note: padding is done with spaces which
788
+ might conflict with tab indentation.
789
+
790
+ Output uses following options (as part second argument, `opts` table):
791
+ - <justify_side> - string or array of strings. Each element can be one of
792
+ "left" (pad right side), "center" (pad both sides equally), "right" (pad
793
+ left side), "none" (no padding). Default: "left".
794
+ - <justify_offsets> - array of numeric left offsets of rows. Used to adjust
795
+ for possible not equal indents, like in case of charwise selection when
796
+ left edge is not on the first column. Default: array of zeros. Set
797
+ automatically during interactive alignment in charwise mode.
798
+
799
+ Return ~
800
+ `(table)` A step named "justify" and with appropriate callable action.
801
+
802
+ ------------------------------------------------------------------------------
803
+ *MiniAlign.gen_step.default_merge()*
804
+ `MiniAlign.gen_step.default_merge`()
805
+ Generate default merge step
806
+
807
+ Output merges rows of parts into strings by placing merge delimiter(s)
808
+ between them.
809
+
810
+ Outline of how parts are converted to array of strings:
811
+ - Convert `merge_delimiter` option to array of strings (single string is
812
+ converted as one-element array). Recycle this array to have length equal
813
+ to number of columns in parts minus 1. Also possibly trim leading whitespace
814
+ in first merge character to not affect indentation.
815
+ - Exclude empty strings from parts. They add nothing to output except extra
816
+ usage of merge delimiter.
817
+ - Concatenate each row interleaving with array of merge delimiters.
818
+
819
+ Output uses following options (as part second argument, `opts` table):
820
+ - <merge_delimiter> - string or array of strings. Default: `''`.
821
+ Examples: `' '`, `{ '', ' ' }`.
822
+
823
+ Return ~
824
+ `(table)` A step named "merge" and with appropriate callable action.
825
+
826
+ ------------------------------------------------------------------------------
827
+ *MiniAlign.gen_step.filter()*
828
+ `MiniAlign.gen_step.filter`({expr})
829
+ Generate filter step
830
+
831
+ Construct function predicate from supplied Lua string expression and make
832
+ step evaluating it on every part element.
833
+
834
+ Outline of how filtering is done:
835
+ - Convert Lua filtering expression into function predicate which can be
836
+ evaluated in manually created context (some specific variables being set).
837
+ - Compute boolean mask for parts by applying predicate to each element of
838
+ 2d array with special variables set to specific values (see next section).
839
+ - Group parts with computed mask. See `group()` method of parts in
840
+ |MiniAlign.as_parts()|.
841
+
842
+ Special variables which can be used in expression:
843
+ - <row> - row number of current element.
844
+ - <ROW> - total number of rows in parts.
845
+ - <col> - column number of current element.
846
+ - <COL> - total number of columns in current row.
847
+ - <s> - string value of current element.
848
+ - <n> - column pair number of current element. Useful when filtering by
849
+ result of pattern splitting.
850
+ - <N> - total number of column pairs in current row.
851
+ - All variables from global table `_G`.
852
+
853
+ Tips:
854
+ - This general filtering approach can be used to both include and exclude
855
+ certain parts from alignment. Examples:
856
+ - Use `row ~= 2` to align all parts except from second row.
857
+ - Use `n == 1` to align only by first pair of columns.
858
+ - Filtering by last equal sign usually can be done with `n >= (N - 1)`
859
+ (because there is usually something to the right of it).
860
+
861
+ Parameters ~
862
+ {expr} `(string)` Lua expression as a string which will be used as predicate.
863
+
864
+ Return ~
865
+ `(table|nil)` A step named "filter" and with appropriate callable action.
866
+
867
+ ------------------------------------------------------------------------------
868
+ *MiniAlign.gen_step.ignore_split()*
869
+ `MiniAlign.gen_step.ignore_split`({patterns}, {exclude_comment})
870
+ Generate ignore step
871
+
872
+ Output adds certain values to `split_exclude_patterns` option. Should be
873
+ used as pre-split step.
874
+
875
+ Parameters ~
876
+ {patterns} `(table)` Array of patterns to be added to
877
+ `split_exclude_patterns` as is. Default: `{ [[".-"]] }` (excludes strings
878
+ for most cases).
879
+ {exclude_comment} `(boolean|nil)` Whether to add comment pattern to
880
+ `split_exclude_patterns`. Comment pattern is derived from |'commentstring'|
881
+ option. Default: `true`.
882
+
883
+ Return ~
884
+ `(table)` A step named "ignore" and with appropriate callable action.
885
+
886
+ See also ~
887
+ |MiniAlign.gen_step.default_split()| for details about
888
+ `split_exclude_patterns` option.
889
+
890
+ ------------------------------------------------------------------------------
891
+ *MiniAlign.gen_step.pair()*
892
+ `MiniAlign.gen_step.pair`({direction})
893
+ Generate pair step
894
+
895
+ Output calls `pair()` method of parts (see |MiniAlign.as_parts()|) with
896
+ supplied `direction` argument.
897
+
898
+ Parameters ~
899
+ {direction} `(string)` Which direction to pair. One of "left" (default) or
900
+
901
+
902
+ Return ~
903
+ `(table)` A step named "pair" and with appropriate callable action.
904
+
905
+ ------------------------------------------------------------------------------
906
+ *MiniAlign.gen_step.trim()*
907
+ `MiniAlign.gen_step.trim`({direction}, {indent})
908
+ Generate trim step
909
+
910
+ Output calls `trim()` method of parts (see |MiniAlign.as_parts()|) with
911
+ supplied `direction` and `indent` arguments.
912
+
913
+ Parameters ~
914
+ {direction} `(string|nil)` Which sides to trim whitespace. One of "both"
915
+ (default), "left", "right", "none".
916
+ {indent} `(string|nil)` What to do with possible indent (left whitespace
917
+ of first string in a row). One of "keep" (default), "low", "high", "remove".
918
+
919
+ Return ~
920
+ `(table)` A step named "trim" and with appropriate callable action.
921
+
922
+
923
+ vim:tw=78:ts=8:noet:ft=help:norl: