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,1535 @@
1
+ *mini.pick* Pick anything
2
+
3
+ MIT License Copyright (c) 2023 Evgeni Chasnovski
4
+
5
+ ------------------------------------------------------------------------------
6
+ *MiniPick*
7
+ Features:
8
+
9
+ - Single window general purpose interface for picking element from any array.
10
+
11
+ - On demand toggleable preview and info views.
12
+
13
+ - Interactive query matching (filter+sort) with fast non-blocking default
14
+ which does fuzzy matching and allows other modes (|MiniPick.default_match()|).
15
+
16
+ - Built-in pickers (see |MiniPick.builtin|):
17
+ - Files.
18
+ - Pattern match (for fixed pattern or with live feedback; both allow
19
+ file filtering via glob patterns).
20
+ - Buffers.
21
+ - Help tags.
22
+ - CLI output.
23
+ - Resume latest picker.
24
+
25
+ - |:Pick| command to work with extensible |MiniPick.registry|.
26
+
27
+ - |vim.ui.select()| implementation. To adjust, use |MiniPick.ui_select()|
28
+ or save-restore `vim.ui.select` manually after calling |MiniPick.setup()|.
29
+
30
+ - Rich and customizable built-in |MiniPick-actions| when picker is active:
31
+ - Manually change currently focused item.
32
+ - Scroll vertically and horizontally.
33
+ - Toggle preview or info view.
34
+ - Mark/unmark items to choose later.
35
+ - Refine current matches (make them part of a new picker).
36
+ - And many more.
37
+
38
+ - Minimal yet flexible |MiniPick-source| specification with:
39
+ - Items (array, callable, or manually set later).
40
+ - Source name.
41
+ - Working directory.
42
+ - Matching algorithm.
43
+ - Way matches are shown in main window.
44
+ - Item preview.
45
+ - "On choice" action for current and marked items.
46
+
47
+ - Custom actions/keys can be configured globally, per buffer, or per picker.
48
+
49
+ - Out of the box support for |'ignorecase'| and |'smartcase'|.
50
+
51
+ - Match caching to increase responsiveness on repeated prompts.
52
+
53
+ Notes:
54
+ - Works on all supported versions but Neovim>=0.10 will give more visual
55
+ feedback in floating window footer.
56
+
57
+ - For more pickers see |MiniExtra.pickers|.
58
+
59
+ Sources with more details:
60
+ - |MiniPick-overview|
61
+ - |MiniPick-source|
62
+ - |MiniPick-actions|
63
+ - |MiniPick-examples|
64
+ - |MiniPick.builtin|
65
+ - |MiniPick-in-other-plugins| (for plugin authors)
66
+
67
+ # Dependencies ~
68
+
69
+ Suggested dependencies (provide extra functionality, will work without them):
70
+
71
+ - Enabled |mini.icons| module to show icons near the items for actual paths.
72
+ Falls back to `nvim-tree/nvim-web-devicons` plugin or no icons will be used.
73
+
74
+ - *MiniPick-cli-tools* CLI tool(s) to power |MiniPick.builtin.files()|,
75
+ |MiniPick.builtin.grep()|, and |MiniPick.builtin.grep_live()| built-in pickers:
76
+ - `rg` (github.com/BurntSushi/ripgrep; enough for all three; recommended).
77
+ - `fd` (github.com/sharkdp/fd; for `files` only).
78
+ - `git` (github.com/git/git; enough for all three).
79
+
80
+ Note: CLI tools are called only with basic arguments needed to get items.
81
+ To customize the output, use their respective configuration approaches.
82
+ Here are some examples of where to start:
83
+ - github.com/BurntSushi/ripgrep/blob/master/GUIDE.md#configuration-file
84
+ - github.com/sharkdp/fd#excluding-specific-files-or-directories
85
+ - git-scm.com/docs/gitignore
86
+
87
+ # Setup ~
88
+
89
+ This module needs a setup with `require('mini.pick').setup({})` (replace
90
+ `{}` with your `config` table). It will create global Lua table `MiniPick`
91
+ which you can use for scripting or manually (with `:lua MiniPick.*`).
92
+
93
+ See |MiniPick.config| for available config settings.
94
+
95
+ You can override runtime config settings locally to buffer inside
96
+ `vim.b.minipick_config` which should have same structure as `MiniPick.config`.
97
+ See |mini.nvim-buffer-local-config| for more details.
98
+
99
+ # Comparisons ~
100
+
101
+ - [nvim-telescope/telescope.nvim](https://github.com/nvim-telescope/telescope.nvim):
102
+ - The main inspiration for this module, so there is significant overlap.
103
+ - Has three (or two) window UI (prompt, matches, preview), while this
104
+ module combines everything in one window. It allows more straightforward
105
+ customization for unusual scenarios.
106
+ - Default match algorithm is somewhat slow, while this module should
107
+ match relatively lag-free for at least 100K+ items.
108
+ - Has many built-in pickers, while this module has handful at its core
109
+ relying on other |mini.nvim| modules to provide more (see |mini.extra|).
110
+
111
+ - [ibhagwan/fzf-lua](https://github.com/ibhagwan/fzf-lua):
112
+ - Mostly same comparison as with `nvim-telescope/telescope.nvim`.
113
+ - Requires [junegunn/fzf](https://github.com/junegunn/fzf) installed to
114
+ power fuzzy matching, while this module provides built-in Lua matching.
115
+
116
+ # Highlight groups ~
117
+ *MiniPick-hl-groups*
118
+
119
+ - `MiniPickBorder` - window border.
120
+ - `MiniPickBorderBusy` - window border while picker is busy processing.
121
+ - `MiniPickBorderText` - non-prompt on border.
122
+ - `MiniPickCursor` - cursor during active picker (hidden by default).
123
+ - `MiniPickIconDirectory` - default icon for directory.
124
+ - `MiniPickIconFile` - default icon for file.
125
+ - `MiniPickHeader` - headers in info buffer and previews.
126
+ - `MiniPickMatchCurrent` - current matched item.
127
+ - `MiniPickMatchMarked` - marked matched items.
128
+ - `MiniPickMatchRanges` - ranges matching query elements.
129
+ - `MiniPickNormal` - basic foreground/background highlighting.
130
+ - `MiniPickPreviewLine` - target line in preview.
131
+ - `MiniPickPreviewRegion` - target region in preview.
132
+ - `MiniPickPrompt` - prompt.
133
+ - `MiniPickPromptCaret` - caret in prompt.
134
+ - `MiniPickPromptPrefix` - prefix of the prompt.
135
+
136
+ To change any highlight group, set it directly with |nvim_set_hl()|.
137
+
138
+ # Using in other plugins ~
139
+ *MiniPick-in-other-plugins*
140
+
141
+ - Prefer using |vim.ui.select()| for more user coverage. Use |MiniPick.start()|
142
+ when synchronous select or its extra capabilities is absolutely necessary.
143
+
144
+ - Perform a `_G.MiniPick ~= nil` check before using any feature. This ensures
145
+ that user explicitly set up the module.
146
+
147
+ ------------------------------------------------------------------------------
148
+ *MiniPick-events*
149
+ To allow user customization and integration of external tools, certain |User|
150
+ autocommand events are triggered under common circumstances:
151
+
152
+ - `MiniPickMatch` - just after updating query matches or setting items.
153
+ - `MiniPickStart` - just after picker has started.
154
+ - `MiniPickStop` - just before picker is stopped.
155
+
156
+ ------------------------------------------------------------------------------
157
+ *MiniPick-overview*
158
+ General idea is to take array of objects, display them with interactive
159
+ filter/sort/navigate/preview, and allow to choose one or more items.
160
+
161
+ # How to start a picker ~
162
+
163
+ - Use |MiniPick.start()| with `opts.source` defining |MiniPick-source|.
164
+ Example: `MiniPick.start({ source = { items = vim.fn.readdir('.') } })`
165
+
166
+ - Use any of |MiniPick.builtin| pickers directly.
167
+ Example: `MiniPick.builtin.files({ tool = 'git' })`
168
+
169
+ - Use |:Pick| command which uses customizable pickers from |MiniPick.registry|.
170
+ Example: `:Pick files tool='git'`
171
+
172
+ # User interface ~
173
+
174
+ UI consists from a single window capable of displaying three different views:
175
+ - "Main" - where current query matches are shown.
176
+ - "Preview" - preview of current item (toggle with `<Tab>`).
177
+ - "Info" - general info about picker and its state (toggle with `<S-Tab>`).
178
+
179
+ Current prompt is displayed at the top left of the window border with vertical
180
+ line indicating caret (current input position).
181
+
182
+ Bottom part of window border displays (in Neovim>=0.10) extra visual feedback:
183
+ - Left part is a picker name.
184
+ - Right part contains information in the format >
185
+
186
+ <current index in matches> | <match count> | <marked count> / <total count>
187
+ <
188
+ When picker is busy (like if there are no items yet set or matching is active)
189
+ window border changes color to be `MiniPickBorderBusy` after `config.delay.busy`
190
+ milliseconds of idle time.
191
+
192
+ # Life cycle ~
193
+
194
+ - Type characters to filter and sort matches. It uses |MiniPick.default_match()|
195
+ with `query` being an array of pressed characters.
196
+ Overview of how it matches:
197
+ - If query starts with `'`, the match is exact.
198
+ - If query starts with `^`, the match is exact at start.
199
+ - If query ends with `$`, the match is exact at end.
200
+ - If query starts with `*`, the match is forced to be fuzzy.
201
+ - Otherwise match is fuzzy.
202
+ - Sorting is done to first minimize match width and then match start.
203
+ Nothing more: no favoring certain places in string, etc.
204
+
205
+ - Type special keys to perform |MiniPick-actions|. Here are some basic ones:
206
+ - `<C-n>` / `<Down>` moves down; `<C-p>` / `<Up>` moves up.
207
+ - `<Left>` / `<Right>` moves prompt caret left / right.
208
+ - `<S-Tab>` toggles information window with all available mappings.
209
+ - `<Tab>` toggles preview.
210
+ - `<C-x>` / `<C-a>` toggles current / all item(s) as (un)marked.
211
+ - `<C-Space>` / `<M-Space>` makes all matches or marked items as new picker.
212
+ - `<CR>` / `<M-CR>` chooses current/marked item(s).
213
+ - `<Esc>` / `<C-c>` stops picker.
214
+
215
+ # Implementation details ~
216
+
217
+ - Processing key typing is done via a dedicated key query process for more
218
+ control over their side effects. As a result, regular mappings don't work
219
+ here and picker's window needs to be current as long as it is shown.
220
+ Changing window focus leads to automatic picker stop (after small delay).
221
+ Not picker related screen changes require explicit |:redraw|.
222
+ - Any picker is non-blocking but waits to return the chosen item. Example:
223
+ `file = MiniPick.builtin.files()` allows other actions to be executed when
224
+ picker is shown while still assigning `file` with value of the chosen item.
225
+
226
+ ------------------------------------------------------------------------------
227
+ *MiniPick-source*
228
+ Source is defined as a `source` field inside one of (in increasing priority):
229
+ - |MiniPick.config| - has global effect.
230
+ - `vim.b.minipick_config` - has buffer-local effect.
231
+ - `opts.source` in picker call - has effect for that particular call.
232
+
233
+ Example of source to choose from |arglist|: >lua
234
+
235
+ { items = vim.fn.argv, name = 'Arglist' }
236
+ <
237
+ Note: this is mostly useful for writing pickers. Can safely skip if you
238
+ want to just use provided pickers.
239
+
240
+ # Items ~
241
+ *MiniPick-source.items*
242
+
243
+ `source.items` defines items to choose from. It should be one of the following:
244
+ - Array of objects which can have different types. Any type is allowed.
245
+ - `nil`. Picker waits for explicit |MiniPick.set_picker_items()| call.
246
+ - Callable returning any of the previous types. Will be called once on start
247
+ with source's `cwd` set as |current-directory|.
248
+
249
+ *MiniPick-source.items-stritems*
250
+ Matching is done for items array based on the string representation of its
251
+ elements (here called "stritems"). For single item it is computed as follows:
252
+ - Callable is called once with output used in next steps.
253
+ - String item is used as is.
254
+ - String <text> field of table item is used (if present).
255
+ - Use output of |vim.inspect()|.
256
+
257
+ Example: >lua
258
+
259
+ items = { 'aaa.txt', { text = 'bbb' }, function() return 'ccc' end }
260
+ -- corresponding stritems are { 'aaa.txt', 'bbb', 'ccc' }
261
+ <
262
+ Default value is `nil`, assuming it always be supplied by the caller.
263
+
264
+ *MiniPick-source.items-common*
265
+ There are some recommendations for common item types in order for them to work
266
+ out of the box with |MiniPick.default_show()|, |MiniPick.default_preview()|,
267
+ |MiniPick.default_choose()|, |MiniPick.default_choose_marked()|:
268
+
269
+ - Path (file or directory). Use string or `path` field of a table. Path can
270
+ be either absolute, relative to the `source.cwd`, or have a general URI format
271
+ (only if supplied as table field).
272
+ Examples: `'aaa.txt'`, `{ path = 'aaa.txt' }`
273
+
274
+ - Buffer. Use buffer id as number, string, or `bufnr` / `buf_id` / `buf`
275
+ field of a table (any name is allowed).
276
+ Examples: `1`, `'1'`, `{ bufnr = 1 }`, `{ buf_id = 1 }`, `{ buf = 1 }`
277
+
278
+ - Line in file or buffer. Use table representation with `lnum` field with line
279
+ number (starting from 1) or string in "<path>\0<line>" format (`\0` is
280
+ an actual null character; don't escape the slash; may need to be `\000`).
281
+ Examples: >lua
282
+
283
+ { path = 'aaa.txt', lnum = 2 }, 'aaa.txt\0002', { bufnr = 1, lnum = 3 }
284
+ <
285
+ - Position in file or buffer. Use table representation with `lnum` and `col`
286
+ fields with line and column numbers (starting from 1) or string in
287
+ "<path>\0<line>\0<col>" format (`\0` is an actual null character, don't
288
+ escape the slash; may need to be `\000`).
289
+ Examples: >lua
290
+
291
+ { path = 'aaa.txt', lnum = 2, col = 3 }, 'aaa.txt\0' .. '2\0003',
292
+ { bufnr = 1, lnum = 3, col = 4 }
293
+ <
294
+ - Region in file or buffer. Use table representation with `lnum`, `col`,
295
+ `end_lnum`, `end_col` fields for start and end line/column. All numbers
296
+ start from 1, end line is inclusive, end column is exclusive.
297
+ This naming is similar to |getqflist()| and |diagnostic-structure|.
298
+ Examples: >lua
299
+
300
+ { path = 'aaa.txt', lnum = 2, col = 3, end_lnum = 4, end_col = 5 },
301
+ { bufnr = 1, lnum = 3, col = 4, end_lnum = 5, end_col = 6 }
302
+ <
303
+ Note: all table items will benefit from having `text` field for better matching.
304
+
305
+ # Name ~
306
+ *MiniPick-source.name*
307
+
308
+ `source.name` defines the name of the picker to be used for visual feedback.
309
+
310
+ Default value is "<No name>".
311
+
312
+ # Current working directory ~
313
+ *MiniPick-source.cwd*
314
+
315
+ `source.cwd` is a string defining the current working directory in which
316
+ picker operates. It should point to a valid actually present directory path.
317
+ This is a part of source to allow persistent way to use relative paths,
318
+ i.e. not depend on current directory being constant after picker start.
319
+ It also makes the |MiniPick.builtin.resume()| picker more robust.
320
+
321
+ It will be set as local |current-directory| (|:lcd|) of picker's main window
322
+ to allow simpler code for "in window" functions (choose/preview/custom/etc.).
323
+
324
+ Default value is |current-directory|.
325
+
326
+ # Match ~
327
+ *MiniPick-source.match*
328
+
329
+ `source.match` is a callable defining how stritems
330
+ (see |MiniPick-source.items-stritems|) are matched (filtered and sorted) based
331
+ on the query.
332
+
333
+ It will be called with the following arguments:
334
+ - `stritems` - all available stritems for current picker.
335
+ - `inds` - array of `stritems` indexes usually pointing at current matches.
336
+ It does point to current matches in the case of interactively appending
337
+ character at the end of the query. It assumes that matches for such bigger
338
+ query is a subset of previous matches (implementation can ignore it).
339
+ This can be utilized to increase performance by checking fewer stritems.
340
+ - `query` - array of strings. Usually (like is common case of user interactively
341
+ typing query) each string represents one character. However, any strings are
342
+ allowed, as query can be set with |MiniPick.set_picker_query()|.
343
+
344
+ It should either return array of match indexes for stritems elements matching
345
+ the query (synchronous) or explicitly use |MiniPick.set_picker_match_inds()|
346
+ to set them (may be asynchronous).
347
+
348
+ Notes:
349
+ - The result can be any array of `stritems` indexes, i.e. not necessarily
350
+ a subset of input `inds`.
351
+
352
+ - Both `stritems` and `query` depend on values of |'ignorecase'| and |'smartcase'|.
353
+ If query shows "ignore case" properties (only |'ignorecase'| is set or both
354
+ |'ignorecase'| / |'smartcase'| are set and query has only lowercase characters),
355
+ then `stritems` and `query` will have only lowercase characters.
356
+ This allows automatic support for case insensitive matching while being
357
+ faster and having simpler match function implementation.
358
+
359
+ - Writing custom `source.match` usually means also changing |MiniPick-source.show|
360
+ because it is used to highlight stritems parts actually matching the query.
361
+
362
+ Example of simple "exact" `match()` preserving initial order: >lua
363
+
364
+ local match_exact = function(stritems, inds, query)
365
+ local prompt_pattern = vim.pesc(table.concat(query))
366
+ local f = function(i) return stritems[i]:find(prompt_pattern) ~= nil end
367
+ return vim.tbl_filter(f, inds)
368
+ end
369
+ -- For non-blocking version see `:h MiniPick.poke_is_picker_active()`
370
+ <
371
+ Default value is |MiniPick.default_match()|.
372
+
373
+ # Show ~
374
+ *MiniPick-source.show*
375
+
376
+ `source.show` is a callable defining how matched items are shown in the window.
377
+
378
+ It will be called with the following arguments:
379
+ - `buf_id` - identifier of the target buffer.
380
+ - `items_to_show` - array of actual items to be shown in `buf_id`. This is
381
+ a subset of currently matched items computed to fit in current window view.
382
+ - `query` - array of strings. Same as in `source.match`.
383
+
384
+ It should update buffer `buf_id` to visually represent `items_to_show`
385
+ __one item per line starting from line one__ (it shouldn't depend on
386
+ `options.content_from_bottom`). This also includes possible visualization
387
+ of which parts of stritem actually matched query.
388
+
389
+ Example (assuming string items; without highlighting): >lua
390
+
391
+ local show_prepend = function(buf_id, items_arr, query)
392
+ local lines = vim.tbl_map(function(x) return 'Item: ' .. x end, items_arr)
393
+ vim.api.nvim_buf_set_lines(buf_id, 0, -1, false, lines)
394
+ end
395
+ <
396
+ Default value is |MiniPick.default_show()|.
397
+
398
+ # Preview ~
399
+ *MiniPick-source.preview*
400
+
401
+ `source.preview` is a callable defining how item preview is done.
402
+
403
+ It will be called with the following arguments:
404
+ - `buf_id` - identifier of the target buffer. Note: for every separate instance
405
+ of item previewing new scratch buffer is be created.
406
+ - `item` - item to preview.
407
+
408
+ It should update buffer `buf_id` to visually represent `item`. It can also
409
+ directly set another buffer in picker's main window, but usually it is more
410
+ robust to update given `buf_id` directly.
411
+
412
+ Example: >lua
413
+
414
+ local preview_inspect = function(buf_id, item)
415
+ local lines = vim.split(vim.inspect(item), '\n')
416
+ vim.api.nvim_buf_set_lines(buf_id, 0, -1, false, lines)
417
+ end
418
+ <
419
+ Default value is |MiniPick.default_preview()|.
420
+
421
+ # Choose an item ~
422
+ *MiniPick-source.choose*
423
+
424
+ `source.choose` is a callable defining what to do when an item is chosen.
425
+
426
+ It will be called with the following arguments:
427
+ - `item` - chosen item. Always non-`nil`.
428
+
429
+ It should perform any intended "choose" action for an item and return
430
+ a value indicating whether picker should continue (i.e. not stop):
431
+ `nil` and `false` will stop picker, other values will continue.
432
+
433
+ Notes:
434
+ - It is called when picker window is still current. Use `windows.target` value
435
+ from |MiniPick.get_picker_state()| output to do something with target window.
436
+
437
+ Example: >lua
438
+
439
+ local choose_file_continue = function(item)
440
+ if vim.fn.filereadable(item) == 0 then return end
441
+ vim.api.nvim_win_call(
442
+ MiniPick.get_picker_state().windows.target,
443
+ function() vim.cmd('edit ' .. item) end
444
+ )
445
+ return true
446
+ end
447
+ <
448
+ Default value is |MiniPick.default_choose()|.
449
+
450
+ # Choose marked items ~
451
+ *MiniPick-source.choose_marked*
452
+
453
+ `source.choose_marked` is a callable defining what to do when marked items
454
+ (see |MiniPick-actions-mark|) are chosen. Serves as a companion to
455
+ `source.choose` which can choose several items.
456
+
457
+ It will be called with the following arguments:
458
+ - `items_marked` - array of marked items. Can be empty.
459
+
460
+ It should perform any intended "choose" action for several items and return
461
+ a value indicating whether picker should continue (i.e. not stop):
462
+ `nil` and `false` will stop picker, other values will continue.
463
+
464
+ Notes:
465
+ - It is called when picker window is still current. Use `windows.target` value
466
+ from |MiniPick.get_picker_state()| output to do something with target window.
467
+
468
+ Example: >lua
469
+
470
+ local choose_marked_print = function(items) print(vim.inspect(items)) end
471
+ <
472
+ Default value is |MiniPick.default_choose_marked()|.
473
+
474
+ ------------------------------------------------------------------------------
475
+ *MiniPick-actions*
476
+ When picker is active, `mappings` table defines a set of special keys which when
477
+ pressed will execute certain actions. Those can be of two types:
478
+ - Built-in: actions present in default `config.mappings`. Can be only overridden
479
+ with a different key.
480
+ - Custom: user defined actions. Should be a table with `char` and `func` fields.
481
+
482
+
483
+ # Built-in ~
484
+
485
+ ## Caret ~
486
+ *MiniPick-actions-caret*
487
+
488
+ User can add character not only at query end, but more generally at caret.
489
+
490
+ - `mappings.caret_left` - move caret to left.
491
+ - `mappings.caret_right` - move caret to right.
492
+
493
+ ## Choose ~
494
+ *MiniPick-actions-choose*
495
+
496
+ Choose is a fundamental action that actually implements the intent of
497
+ calling a picker, i.e. pick an item.
498
+
499
+ - `mappings.choose` - choose as is, i.e. apply `source.choose` for current item.
500
+ - `mappings.choose_in_split` - make horizontal split at target window, update
501
+ target window to the new split, and choose.
502
+ - `mappings.choose_in_tabpage` - same as `choose_in_split`, but create tabpage.
503
+ - `mappings.choose_in_vsplit` - same as `choose_in_split`, but split vertically.
504
+ - `mappings.choose_marked` - choose marked items as is, i.e.
505
+ apply `source.choose_marked` at current marked items.
506
+
507
+ ## Delete ~
508
+ *MiniPick-actions-delete*
509
+
510
+ Delete actions are for deleting elements from query.
511
+
512
+ - `mappings.delete_char` - delete one character to the left.
513
+ - `mappings.delete_char_right` - delete one character to the right.
514
+ - `mappings.delete_left` - delete everything to the left (like |i_CTRL-U|).
515
+ - `mappings.delete_word` - delete word to the left (like |i_CTRL-W|).
516
+
517
+ ## Mark ~
518
+ *MiniPick-actions-mark*
519
+
520
+ Marking is an action of adding certain items to a separate list which then can
521
+ be chosen with `mappings.choose_marked` (for example, sent to quickfix list).
522
+ This is a companion to a regular choosing which can pick only one item.
523
+
524
+ - `mappings.mark` - toggle marked/unmarked state of current item.
525
+ - `mappings.mark_all` - toggle marked/unmarked state (mark all if not all
526
+ marked; unmark all otherwise) of all currently matched items.
527
+
528
+ Notes:
529
+ - Marks persist across queries and matches. For example, user can make a query
530
+ with marking all matches several times and marked items from all queries
531
+ will be preserved.
532
+
533
+ ## Move ~
534
+ *MiniPick-actions-move*
535
+
536
+ Move is a fundamental action of changing which item is current.
537
+
538
+ - `mappings.move_down` - change focus to the item below.
539
+ - `mappings.move_start` change focus to the first currently matched item.
540
+ - `mappings.move_up` - change focus to the item above.
541
+
542
+ Notes:
543
+ - Up and down wrap around edges: `move_down` on last item moves to first,
544
+ `move_up` on first moves to last.
545
+ - Moving when preview or info view is shown updates the view with new item.
546
+ - There are also hard-coded alternative keys (can be used for other actions):
547
+ - `<Down>` moves down.
548
+ - `<Home>` moves to first currently matched item.
549
+ - `<Up>` moves up.
550
+
551
+ ## Paste ~
552
+ *MiniPick-actions-paste*
553
+
554
+ Paste is an action to paste content of |registers| at caret.
555
+
556
+ - `mappings.paste` - paste from register defined by the next key press.
557
+
558
+ Notes:
559
+ - Does not support expression register `=`.
560
+ - Supports special cases of register: <C-f> (as |c_CTRL-R_CTRL-F|),
561
+ <C-w> (as |c_CTRL-R_CTRL-W|), <C-a> (as |c_CTRL-R_CTRL-A|),
562
+ <C-l> (as |c_CTRL-R_CTRL-L|).
563
+ - Pasting from system |clipboard| is supported for "non-streaming" paste (as
564
+ described in |vim.paste()|). Use terminal's key combo instead of this action.
565
+
566
+ ## Refine ~
567
+ *MiniPick-actions-refine*
568
+
569
+ Refine is an action that primarily executes the following:
570
+ - Takes certain items and makes them be all items (in order they are present).
571
+ - Resets query.
572
+ - Updates `source.match` to be the one from config.
573
+
574
+ - `mappings.refine` - refine currently matched items.
575
+ - `mappings.refine_marked` - refine currently marked items.
576
+
577
+ This action is useful in at least two cases:
578
+ - Perform consecutive "narrowing" queries. Example: to get items that contain
579
+ both `hello` and `world` exact matches (in no particular order) with default
580
+ matching, type `'hello` (notice `'` at the start) followed by <C-Space> and
581
+ another `'world`.
582
+ - Reset `match` to default. Particularly useful in |MiniPick.builtin.grep_live()|
583
+ and |MiniExtra.pickers.lsp()| with "workspace_symbol_live" scope.
584
+
585
+ ## Scroll ~
586
+ *MiniPick-actions-scroll*
587
+
588
+ Scroll is an action to either move current item focus further than to the
589
+ neighbor item or adjust window view to see more information.
590
+
591
+ - `mappings.scroll_down` - when matches are shown, go down by the amount of
592
+ visible matches. In preview and info view - scroll down as with |CTRL-F|.
593
+ - `mappings.scroll_left` - scroll left as with |zH|.
594
+ - `mappings.scroll_right` - scroll right as with |zL|.
595
+ - `mappings.scroll_up` - when matches are shown, go up by the amount of
596
+ visible matches. In preview and info view - scroll up as with |CTRL-B|.
597
+
598
+ ## Stop ~
599
+ *MiniPick-actions-stop*
600
+
601
+ `mappings.stop` stops the picker. <C-c> also always stops the picker.
602
+
603
+
604
+ ## Toggle ~
605
+ *MiniPick-actions-toggle*
606
+
607
+ Toggle action is a way to change view: show if target is not shown, reset to
608
+ main view otherwise.
609
+
610
+ - `mappings.toggle_info` - toggle info view.
611
+ - `mappings.toggle_preview` - toggle preview.
612
+
613
+ Note:
614
+ - Updating query in any way resets window view to show matches.
615
+ - Moving current item focus keeps preview or info view with updated item.
616
+
617
+ # Custom ~
618
+ *MiniPick-actions-custom*
619
+
620
+ Along with built-in actions, users can define custom actions. This can be
621
+ done by supplying custom elements to `mappings` table. The field defines action
622
+ name (used to infer an action description in info view). The value is a table
623
+ with the following fields:
624
+ - <char> `(string)` - single character acting as action trigger.
625
+ - <func> `(function)` - callable to be executed without arguments after
626
+ user presses <char>. Its return value is treated as "should stop picker
627
+ after execution", i.e. returning nothing, `nil`, or `false` continues
628
+ picker while everything else (prefer `true`) stops it.
629
+
630
+ Example of `execute` custom mapping: >lua
631
+
632
+ execute = {
633
+ char = '<C-e>',
634
+ func = function() vim.cmd(vim.fn.input('Execute: ')) end,
635
+ }
636
+ <
637
+ ------------------------------------------------------------------------------
638
+ *MiniPick-examples*
639
+ # Disable icons ~
640
+
641
+ Disable icons in |MiniPick.builtin| pickers related to paths: >lua
642
+
643
+ local pick = require('mini.pick')
644
+ pick.setup({ source = { show = pick.default_show } })
645
+ <
646
+ # Switch toggle and move keys ~
647
+ >lua
648
+ require('mini.pick').setup({
649
+ mappings = {
650
+ toggle_info = '<C-k>',
651
+ toggle_preview = '<C-p>',
652
+ move_down = '<Tab>',
653
+ move_up = '<S-Tab>',
654
+ }
655
+ })
656
+ <
657
+ # Different window styles ~
658
+ >lua
659
+ -- Different border
660
+ { window = { config = { border = 'double' } } }
661
+
662
+ -- "Cursor tooltip"
663
+ {
664
+ window = {
665
+ config = {
666
+ relative = 'cursor', anchor = 'NW',
667
+ row = 0, col = 0, width = 40, height = 20,
668
+ },
669
+ },
670
+ }
671
+
672
+ -- Centered on screen
673
+ local win_config = function()
674
+ local height = math.floor(0.618 * vim.o.lines)
675
+ local width = math.floor(0.618 * vim.o.columns)
676
+ return {
677
+ anchor = 'NW', height = height, width = width,
678
+ row = math.floor(0.5 * (vim.o.lines - height)),
679
+ col = math.floor(0.5 * (vim.o.columns - width)),
680
+ }
681
+ end
682
+ { window = { config = win_config } }
683
+ <
684
+ ------------------------------------------------------------------------------
685
+ *MiniPick.setup()*
686
+ `MiniPick.setup`({config})
687
+ Module setup
688
+
689
+ # :Pick ~
690
+ *:Pick*
691
+
692
+ Calling this function creates a `:Pick` user command. It takes picker name
693
+ from |MiniPick.registry| as mandatory first argument and executes it with
694
+ following (expanded, |expandcmd()|) |<f-args>| combined in a single table.
695
+ To add custom pickers, update |MiniPick.registry|.
696
+
697
+ Example: >vim
698
+
699
+ :Pick files tool='git'
700
+ :Pick grep pattern='<cword>'
701
+ <
702
+
703
+ It also sets custom |vim.ui.select()| implementation to use the module.
704
+ See |MiniPick.ui_select()|.
705
+
706
+ Parameters ~
707
+ {config} `(table|nil)` Module config table. See |MiniPick.config|.
708
+
709
+ Usage ~
710
+ >lua
711
+ require('mini.pick').setup() -- use default config
712
+ -- OR
713
+ require('mini.pick').setup({}) -- replace {} with your config table
714
+ <
715
+ ------------------------------------------------------------------------------
716
+ *MiniPick.config*
717
+ `MiniPick.config`
718
+ Defaults ~
719
+ >lua
720
+ MiniPick.config = {
721
+ -- Delays (in ms; should be at least 1)
722
+ delay = {
723
+ -- Delay between forcing asynchronous behavior
724
+ async = 10,
725
+
726
+ -- Delay between computation start and visual feedback about it
727
+ busy = 50,
728
+ },
729
+
730
+ -- Keys for performing actions. See `:h MiniPick-actions`.
731
+ mappings = {
732
+ caret_left = '<Left>',
733
+ caret_right = '<Right>',
734
+
735
+ choose = '<CR>',
736
+ choose_in_split = '<C-s>',
737
+ choose_in_tabpage = '<C-t>',
738
+ choose_in_vsplit = '<C-v>',
739
+ choose_marked = '<M-CR>',
740
+
741
+ delete_char = '<BS>',
742
+ delete_char_right = '<Del>',
743
+ delete_left = '<C-u>',
744
+ delete_word = '<C-w>',
745
+
746
+ mark = '<C-x>',
747
+ mark_all = '<C-a>',
748
+
749
+ move_down = '<C-n>',
750
+ move_start = '<C-g>',
751
+ move_up = '<C-p>',
752
+
753
+ paste = '<C-r>',
754
+
755
+ refine = '<C-Space>',
756
+ refine_marked = '<M-Space>',
757
+
758
+ scroll_down = '<C-f>',
759
+ scroll_left = '<C-h>',
760
+ scroll_right = '<C-l>',
761
+ scroll_up = '<C-b>',
762
+
763
+ stop = '<Esc>',
764
+
765
+ toggle_info = '<S-Tab>',
766
+ toggle_preview = '<Tab>',
767
+ },
768
+
769
+ -- General options
770
+ options = {
771
+ -- Whether to show content from bottom to top
772
+ content_from_bottom = false,
773
+
774
+ -- Whether to cache matches (more speed and memory on repeated prompts)
775
+ use_cache = false,
776
+ },
777
+
778
+ -- Source definition. See `:h MiniPick-source`.
779
+ source = {
780
+ items = nil,
781
+ name = nil,
782
+ cwd = nil,
783
+
784
+ match = nil,
785
+ show = nil,
786
+ preview = nil,
787
+
788
+ choose = nil,
789
+ choose_marked = nil,
790
+ },
791
+
792
+ -- Window related options
793
+ window = {
794
+ -- Float window config (table or callable returning it)
795
+ config = nil,
796
+
797
+ -- String to use as caret in prompt
798
+ prompt_caret = '▏',
799
+
800
+ -- String to use as prefix in prompt
801
+ prompt_prefix = '> ',
802
+ },
803
+ }
804
+ <
805
+ # Delays ~
806
+
807
+ `config.delay` defines plugin delays (in ms). All should be strictly positive.
808
+
809
+ `delay.async` is a delay between forcing asynchronous behavior. This usually
810
+ means forcing |:redraw| in preview (several but limited number of times to
811
+ ensure visible async highlighting) and using |MiniPick.poke_is_picker_active()|
812
+ (for example, to stop current matching if query has updated).
813
+ Smaller values give smoother user experience at the cost of more computations.
814
+
815
+ `delay.busy` is a delay between when some computation starts and showing
816
+ visual feedback about it by making window border to have `MiniPickBorderBusy`
817
+ highlight group.
818
+ Smaller values will give feedback faster at the cost of feeling like flicker.
819
+
820
+ # Mappings ~
821
+
822
+ `config.mappings` defines keys for special actions to be triggered after certain
823
+ keys. See |MiniPick-actions| for more information.
824
+
825
+ # Options ~
826
+
827
+ `config.options` contains some general purpose options.
828
+
829
+ `options.content_from_bottom` is a boolean indicating whether content should be
830
+ shown from bottom to top. That means that best matches will be shown at
831
+ the bottom. Note: for better experience use Neovim>=0.10, which has floating
832
+ window footer capability. Default: `false`.
833
+
834
+ `options.use_cache` is a boolean indicating whether match results should be
835
+ cached per prompt (i.e. concatenated query). This results into faster response
836
+ on repeated prompts (like when deleting query entries) at the cost of using
837
+ more memory. Default: `false`.
838
+
839
+ # Source ~
840
+
841
+ `config.source` defines fallbacks for source specification. For example, this
842
+ can be used to change default `match` to use different implementation or `show`
843
+ to not show icons for some |MiniPick.builtin| pickers (see |MiniPick-examples|).
844
+ See |MiniPick-source| for more information.
845
+
846
+ # Window ~
847
+
848
+ `config.window` contains window specific configurations.
849
+
850
+ `window.config` defines a (parts of) default floating window config for the main
851
+ picker window. This can be either a table overriding some parts or a callable
852
+ returning such table. See |MiniPick-examples| for some examples.
853
+
854
+ `window.prompt_caret` defines how caret is displayed in window's prompt.
855
+ Default: `'▏'`.
856
+
857
+ `window.prompt_prefix` defines what prefix is used in window's prompt.
858
+ Default: `'> '`.
859
+
860
+ ------------------------------------------------------------------------------
861
+ *MiniPick.start()*
862
+ `MiniPick.start`({opts})
863
+ Start picker
864
+
865
+ Notes:
866
+ - If there is currently an active picker, it is properly stopped and new one
867
+ is started "soon" in the main event-loop (see |vim.schedule()|).
868
+ - Current window at the moment of this function call is treated as "target".
869
+ It will be set back as current after |MiniPick.stop()|.
870
+ See |MiniPick.get_picker_state()| and |MiniPick.set_picker_target_window()|.
871
+
872
+ Parameters ~
873
+ {opts} `(table|nil)` Options. Should have same structure as |MiniPick.config|.
874
+ Default values are inferred from there.
875
+ Usually should have proper |MiniPick-source.items| defined.
876
+
877
+ Return ~
878
+ `(any)` Item which was current when picker is stopped; `nil` if aborted.
879
+
880
+ ------------------------------------------------------------------------------
881
+ *MiniPick.stop()*
882
+ `MiniPick.stop`()
883
+ Stop active picker
884
+
885
+ ------------------------------------------------------------------------------
886
+ *MiniPick.refresh()*
887
+ `MiniPick.refresh`()
888
+ Refresh active picker
889
+
890
+ ------------------------------------------------------------------------------
891
+ *MiniPick.default_match()*
892
+ `MiniPick.default_match`({stritems}, {inds}, {query}, {opts})
893
+ Default match
894
+
895
+ Filter target stritems to contain query and sort from best to worst matches.
896
+
897
+ Implements default value for |MiniPick-source.match|.
898
+
899
+ By default (if no special modes apply) it does the following fuzzy matching:
900
+
901
+ - Stritem contains query if it contains all its elements verbatim in the same
902
+ order (possibly with gaps, i.e. not strictly one after another).
903
+ Note: empty query and empty string element is contained in any string.
904
+
905
+ - Sorting is done with the following ordering (same as in |mini.fuzzy|):
906
+ - The smaller the match width (end column minus start column) the better.
907
+ - Among same match width, the smaller start column the better.
908
+ - Among same match width and start column, preserve original order.
909
+
910
+ Notes:
911
+ - Most common interactive usage results into `query` containing one typed
912
+ character per element.
913
+
914
+ # Special modes ~
915
+
916
+ - Forced modes:
917
+ - Query starts with `*`: match the rest fuzzy (without other modes).
918
+ - Query starts with `'`: match the rest exactly (without gaps).
919
+
920
+ - Place modes:
921
+ - Query starts with `^`: match the rest exactly at start.
922
+ - Query ends with `$`: match the rest exactly at end.
923
+ - Both modes can be used simultaneously.
924
+
925
+ - Grouped: query contains at least one whitespace element. Output is computed
926
+ as if query is split at whitespace indexes with concatenation between them.
927
+
928
+ Precedence of modes:
929
+ "forced exact" = "forced fuzzy" > "place start/end" > "grouped" > "default"
930
+
931
+ # Examples ~
932
+
933
+ Assuming `stritems` are `{ '_abc', 'a_bc', 'ab_c', 'abc_' }`, here are some
934
+ example matches based on prompt (concatenated query): >
935
+
936
+ | Prompt | Matches |
937
+ |--------|------------------------|
938
+ | abc | All |
939
+ | *abc | All |
940
+ | | |
941
+ | 'abc | abc_, _abc |
942
+ | *'abc | None (no "'" in items) |
943
+ | | |
944
+ | ^abc | abc_ |
945
+ | *^abc | None (no "^" in items) |
946
+ | | |
947
+ | abc$ | _abc |
948
+ | *abc$ | None (no "$" in items) |
949
+ | | |
950
+ | ab c | abc_, _abc, ab_c |
951
+ | *ab c | None (no " " in items) |
952
+ <
953
+ Having query `{ 'ab', 'c' }` is the same as "ab c" prompt.
954
+
955
+ You can have a feel of how this works with this command: >lua
956
+
957
+ MiniPick.start({ source = { items = { '_abc', 'a_bc', 'ab_c', 'abc_' } } })
958
+ <
959
+ Parameters ~
960
+ {stritems} `(table)` Array of all stritems.
961
+ {inds} `(table)` Array of `stritems` indexes to match. All of them should point
962
+ at string elements of `stritems`. No check is done for performance reasons.
963
+ {query} `(table)` Array of strings.
964
+ {opts} `(table|nil)` Options. Possible fields:
965
+ - <sync> `(boolean)` - Whether to match synchronously. Default: `false`.
966
+ - <preserve_order> `(boolean)` - Whether to skip sort step. Default: `false`.
967
+
968
+ Return ~
969
+ `(table|nil)` Depending on whether computation is synchronous (either `opts.sync`
970
+ is `true` or there is an active picker):
971
+ - If yes, array of `stritems` indexes matching the `query` (from best to worst).
972
+ - If no, `nil` is returned with |MiniPick.set_picker_match_inds()| used later.
973
+
974
+ ------------------------------------------------------------------------------
975
+ *MiniPick.default_show()*
976
+ `MiniPick.default_show`({buf_id}, {items}, {query}, {opts})
977
+ Default show
978
+
979
+ Show items in a buffer and highlight parts that actually match query (assuming
980
+ match is done with |MiniPick.default_match()|). Lines are computed based on
981
+ the |MiniPick-source.items-stritems|.
982
+
983
+ Implements default value for |MiniPick-source.show|.
984
+
985
+ Uses the following highlight groups (see |mini.pick| for their description):
986
+
987
+ - `MiniPickIconDirectory`
988
+ - `MiniPickIconFile`
989
+ - `MiniPickMatchCurrent`
990
+ - `MiniPickMatchMarked`
991
+ - `MiniPickMatchRanges`
992
+
993
+ Parameters ~
994
+ {buf_id} `(number)` Identifier of target buffer.
995
+ {items} `(table)` Array of items to show.
996
+ {query} `(table)` Array of strings representing query.
997
+ {opts} `(table|nil)` Options. Possible fields:
998
+ - <show_icons> `(boolean)` - whether to show icons for entries recognized as
999
+ valid actually present paths on disk (see |MiniPick-source.items-common|),
1000
+ empty space otherwise. Tries to use `text` field as fallback for path.
1001
+ Default: `false`. Note: |MiniPick.builtin| pickers showing file/directory
1002
+ paths use `true` by default.
1003
+ - <icons> `(table)` - table with fallback icons used if icon provider
1004
+ does not itself supply default icons for category. Can have fields:
1005
+ - <directory> `(string)` - icon for directory. Default: " ".
1006
+ - <file> `(string)` - icon for file. Default: " ".
1007
+ - <none> `(string)` - icon for non-valid path. Default: " ".
1008
+
1009
+ ------------------------------------------------------------------------------
1010
+ *MiniPick.default_preview()*
1011
+ `MiniPick.default_preview`({buf_id}, {item}, {opts})
1012
+ Default preview
1013
+
1014
+ Preview item. Logic follows the rules in |MiniPick-source.items-common|:
1015
+ - File and buffer are shown at the start.
1016
+ - Directory has its content listed.
1017
+ - Line/position/region in file or buffer is shown at start.
1018
+ - Others are shown directly with |vim.inspect()|.
1019
+
1020
+ Implements default value for |MiniPick-source.preview|.
1021
+
1022
+ Uses the following highlight groups (see |mini.pick| for their description):
1023
+
1024
+ - `MiniPickPreviewLine`
1025
+ - `MiniPickPreviewRegion`
1026
+
1027
+ Parameters ~
1028
+ {buf_id} `(number)` Identifier of target buffer.
1029
+ {item} `(any)` Item to preview.
1030
+ {opts} `(table|nil)` Options. Possible values:
1031
+ - <n_context_lines> `(number)` - number of lines to load past target position
1032
+ when reading from disk. Useful to explore context. Default: |'lines'| twice.
1033
+ - <line_position> `(string)` - where in the window to show item position.
1034
+ One of "top", "center", "bottom". Default: "top".
1035
+
1036
+ ------------------------------------------------------------------------------
1037
+ *MiniPick.default_choose()*
1038
+ `MiniPick.default_choose`({item})
1039
+ Default choose
1040
+
1041
+ Choose item. Logic follows the rules in |MiniPick-source.items-common|:
1042
+ - File uses |bufadd()| and sets cursor at the start of line/position/region.
1043
+ - Buffer is set as current in target window and sets cursor similarly.
1044
+ - Directory is called with |:edit| in the target window.
1045
+ - Others have the output of |vim.inspect()| printed in Command line.
1046
+
1047
+ Implements default value for |MiniPick-source.choose|.
1048
+
1049
+ Parameters ~
1050
+ {item} `(any)` Item to choose.
1051
+
1052
+ ------------------------------------------------------------------------------
1053
+ *MiniPick.default_choose_marked()*
1054
+ `MiniPick.default_choose_marked`({items}, {opts})
1055
+ Default choose marked items
1056
+
1057
+ Choose marked items. Logic follows the rules in |MiniPick-source.items-common|:
1058
+ - If among items there is at least one file or buffer, quickfix list is opened
1059
+ with all file or buffer lines/positions/regions.
1060
+ - Otherwise, picker's `source.choose` is called on the first item.
1061
+
1062
+ Implements default value for |MiniPick-source.choose_marked|.
1063
+
1064
+ Parameters ~
1065
+ {items} `(table)` Array of items to choose.
1066
+ {opts} `(table|nil)` Options. Possible fields:
1067
+ - <list_type> `(string)` - which type of list to open. One of "quickfix"
1068
+ or "location". Default: "quickfix".
1069
+
1070
+ ------------------------------------------------------------------------------
1071
+ *MiniPick.ui_select()*
1072
+ `MiniPick.ui_select`({items}, {opts}, {on_choice}, {start_opts})
1073
+ Select rewrite
1074
+
1075
+ Function which can be used to directly override |vim.ui.select()| to use
1076
+ |mini.pick| for any "select" type of tasks.
1077
+ Set automatically in |MiniPick.setup()|.
1078
+
1079
+ Implements required by `vim.ui.select()` signature, with some differences:
1080
+ - Allows `opts.preview_item` that returns one of:
1081
+ - Array of lines for item preview.
1082
+ - Preview data described in |vim.ui.select()| (on Neovim>=0.12.3).
1083
+ - Allows fourth `start_opts` argument to customize |MiniPick.start()| call.
1084
+
1085
+ Notes:
1086
+ - `on_choice` with selected item is called when target window is current.
1087
+ - If a picker is active, start a new one after the current one is stopped.
1088
+
1089
+ Usage ~
1090
+ >lua
1091
+ -- Customize with fourth argument inside a function wrapper
1092
+ vim.ui.select = function(items, opts, on_choice)
1093
+ local start_opts = { window = { config = { width = vim.o.columns } } }
1094
+ return MiniPick.ui_select(items, opts, on_choice, start_opts)
1095
+ end
1096
+ <
1097
+ To preserve original `vim.ui.select()`: >lua
1098
+
1099
+ local ui_select_orig = vim.ui.select
1100
+ require('mini.pick').setup()
1101
+ vim.ui.select = ui_select_orig
1102
+ <
1103
+ ------------------------------------------------------------------------------
1104
+ *MiniPick.builtin*
1105
+ `MiniPick.builtin`
1106
+ Table with built-in pickers
1107
+
1108
+ ------------------------------------------------------------------------------
1109
+ *MiniPick.builtin.files()*
1110
+ `MiniPick.builtin.files`({local_opts}, {opts})
1111
+ Pick from files
1112
+
1113
+ Lists all files recursively in all subdirectories. Tries to use one of the
1114
+ CLI tools to create items (see |MiniPick-cli-tools|): `rg`, `fd`, `git`.
1115
+ If none is present, uses fallback which utilizes |vim.fs.dir()|.
1116
+
1117
+ To customize CLI tool search, either use tool's global configuration approach
1118
+ or directly |MiniPick.builtin.cli()| with specific command.
1119
+
1120
+ Parameters ~
1121
+ {local_opts} `(table|nil)` Options defining behavior of this particular picker.
1122
+ Possible fields:
1123
+ - <tool> `(string)` - which tool to use. One of "rg", "fd", "git", "fallback".
1124
+ Default: whichever tool is present, trying in that same order.
1125
+ {opts} `(table|nil)` Options forwarded to |MiniPick.start()|.
1126
+
1127
+ ------------------------------------------------------------------------------
1128
+ *MiniPick.builtin.grep()*
1129
+ `MiniPick.builtin.grep`({local_opts}, {opts})
1130
+ Pick from pattern matches
1131
+
1132
+ Lists all pattern matches recursively in all subdirectories.
1133
+ Tries to use one of the CLI tools to create items (see |MiniPick-cli-tools|):
1134
+ `rg`, `git`. If none is present, uses fallback which utilizes |vim.fs.dir()| and
1135
+ Lua pattern matches (NOT recommended in large directories).
1136
+
1137
+ To customize CLI tool search, either use tool's global configuration approach
1138
+ or directly |MiniPick.builtin.cli()| with specific command.
1139
+ Options |'ignorecase'| and |'smartcase'| are respected via forcing appropriate
1140
+ flags to CLI tool (i.e. overriding tool's global config).
1141
+
1142
+ Parameters ~
1143
+ {local_opts} `(table|nil)` Options defining behavior of this particular picker.
1144
+ Possible fields:
1145
+ - <tool> `(string)` - which tool to use. One of "rg", "git", "fallback".
1146
+ Default: whichever tool is present, trying in that same order.
1147
+ - <pattern> `(string)` - string pattern to search. If not given, asks user
1148
+ interactively with |MiniInput.get()| (if enabled) or |input()|.
1149
+ - <globs> `(table)` - array of string glob patterns to restrict search to
1150
+ matching files. Supported only by "rg" and "git" tools, respects their
1151
+ specific glob syntax and effects. Default: `{}` (no restriction).
1152
+ Example: `{ '*.lua', 'lua/**' }` for Lua files and files in "lua" directory.
1153
+ - <method> `(string)` - pattern matching method: `"regex"` (default) or `"plain"`.
1154
+ {opts} `(table|nil)` Options forwarded to |MiniPick.start()|.
1155
+
1156
+ ------------------------------------------------------------------------------
1157
+ *MiniPick.builtin.grep_live()*
1158
+ `MiniPick.builtin.grep_live`({local_opts}, {opts})
1159
+ Pick from pattern matches with live feedback
1160
+
1161
+ Perform pattern matching treating prompt as pattern. Gives live feedback on
1162
+ which matches are found. Use |MiniPick-actions-refine| to revert to regular
1163
+ matching. Use <C-o> to restrict search to files matching glob patterns.
1164
+ Use <C-e> to change pattern matching method. Tries to use one of the CLI
1165
+ tools to create items (see |MiniPick-cli-tools|): `rg`, `git`. If none is
1166
+ present, error is thrown (for performance reasons).
1167
+
1168
+ To customize search, use tool's global configuration approach.
1169
+ Options |'ignorecase'| and |'smartcase'| are respected via forcing appropriate
1170
+ flags to CLI tool (i.e. overriding tool's global config).
1171
+
1172
+ Parameters ~
1173
+ {local_opts} `(table|nil)` Options defining behavior of this particular picker.
1174
+ Possible fields:
1175
+ - <tool> `(string)` - which tool to use. One of "rg", "git".
1176
+ Default: whichever tool is present, trying in that same order.
1177
+ - <globs> `(table)` - array of string glob patterns to restrict search to
1178
+ matching files. Supported only by "rg" and "git" tools, respects their
1179
+ specific glob syntax and effects. Default: `{}` (no restriction).
1180
+ Example: `{ '*.lua', 'lua/**' }` for Lua files and files in "lua" directory.
1181
+ Use <C-o> custom mapping to add glob to the array. It uses |MiniInput.get()|
1182
+ (if enabled) to show input in |'winbar'| or |'statusline'| (depending of
1183
+ whether content is from bottom).
1184
+ - <method> `(string)` - pattern matching method: `"regex"` (default) or `"plain"`.
1185
+ Use <C-e> custom mapping to add glob to the array.
1186
+ {opts} `(table|nil)` Options forwarded to |MiniPick.start()|.
1187
+
1188
+ ------------------------------------------------------------------------------
1189
+ *MiniPick.builtin.help()*
1190
+ `MiniPick.builtin.help`({local_opts}, {opts})
1191
+ Pick from help tags
1192
+
1193
+ Notes:
1194
+ - On choose directly executes |:help| command with appropriate modifier
1195
+ (none, |:vertical|, |:tab|). This is done through custom mappings named
1196
+ `show_help_in_{split,vsplit,tab}`. Not `choose_in_{split,vsplit,tab}` because
1197
+ there is no split guarantee (like if there is already help window opened).
1198
+
1199
+ Parameters ~
1200
+ {local_opts} `(table|nil)` Options defining behavior of this particular picker.
1201
+ Possible fields:
1202
+ - <default_split> `(string)` - direction of a split for `choose` action.
1203
+ One of "horizontal", "vertical", "tab". Default: "horizontal".
1204
+ {opts} `(table|nil)` Options forwarded to |MiniPick.start()|.
1205
+
1206
+ ------------------------------------------------------------------------------
1207
+ *MiniPick.builtin.buffers()*
1208
+ `MiniPick.builtin.buffers`({local_opts}, {opts})
1209
+ Pick from buffers
1210
+
1211
+ Notes:
1212
+ - There are not built-in mappings for buffer manipulation. Here is an example
1213
+ of how to call this function with mapping to wipeout the current item: >lua
1214
+
1215
+ local wipeout_cur = function()
1216
+ vim.api.nvim_buf_delete(MiniPick.get_picker_matches().current.bufnr, {})
1217
+ end
1218
+ local buffer_mappings = { wipeout = { char = '<C-d>', func = wipeout_cur } }
1219
+ MiniPick.builtin.buffers(local_opts, { mappings = buffer_mappings })
1220
+ <
1221
+ Parameters ~
1222
+ {local_opts} `(table|nil)` Options defining behavior of this particular picker.
1223
+ Possible fields:
1224
+ - <include_current> `(boolean)` - whether to include current buffer in
1225
+ the output. Default: `true`.
1226
+ - <include_unlisted> `(boolean)` - whether to include |unlisted-buffer|s in
1227
+ the output. Default: `false`.
1228
+ {opts} `(table|nil)` Options forwarded to |MiniPick.start()|.
1229
+
1230
+ ------------------------------------------------------------------------------
1231
+ *MiniPick.builtin.cli()*
1232
+ `MiniPick.builtin.cli`({local_opts}, {opts})
1233
+ Pick from CLI output
1234
+
1235
+ Executes command line tool and constructs items based on its output.
1236
+ Uses |MiniPick.set_picker_items_from_cli()|.
1237
+
1238
+ Example: `MiniPick.builtin.cli({ command = { 'echo', 'a\nb\nc' } })`
1239
+
1240
+ Parameters ~
1241
+ {local_opts} `(table|nil)` Options defining behavior of this particular picker.
1242
+ Possible fields:
1243
+ - <command> `(table)` - forwarded to `set_picker_items_from_cli()`.
1244
+ - <postprocess> `(function)` - forwarded to `set_picker_items_from_cli()`.
1245
+ - <spawn_opts> `(table)` - forwarded to `set_picker_items_from_cli()`.
1246
+ Note: if `cwd` field is absent, it is inferred from |MiniPick-source.cwd|.
1247
+ {opts} `(table|nil)` Options forwarded to |MiniPick.start()|.
1248
+
1249
+ ------------------------------------------------------------------------------
1250
+ *MiniPick.builtin.resume()*
1251
+ `MiniPick.builtin.resume`()
1252
+ Resume latest picker
1253
+
1254
+ ------------------------------------------------------------------------------
1255
+ *MiniPick.registry*
1256
+ `MiniPick.registry`
1257
+ Picker registry
1258
+
1259
+ Place for users and extensions to manage pickers with their commonly used
1260
+ local options. By default contains all |MiniPick.builtin| pickers.
1261
+ All entries should accept only a single `local_opts` table argument.
1262
+
1263
+ Serves as a source for |:Pick| command.
1264
+
1265
+ Customization examples: >lua
1266
+
1267
+ -- Adding custom picker to pick `register` entries
1268
+ MiniPick.registry.registry = function()
1269
+ local items = vim.tbl_keys(MiniPick.registry)
1270
+ table.sort(items)
1271
+ local source = {items = items, name = 'Registry', choose = function() end}
1272
+ local chosen_picker_name = MiniPick.start({ source = source })
1273
+ if chosen_picker_name == nil then return end
1274
+ return MiniPick.registry[chosen_picker_name]()
1275
+ end
1276
+
1277
+ -- Make `:Pick files` accept `cwd`
1278
+ MiniPick.registry.files = function(local_opts)
1279
+ local opts = { source = { cwd = local_opts.cwd } }
1280
+ local_opts.cwd = nil
1281
+ return MiniPick.builtin.files(local_opts, opts)
1282
+ end
1283
+ <
1284
+ ------------------------------------------------------------------------------
1285
+ *MiniPick.get_picker_items()*
1286
+ `MiniPick.get_picker_items`()
1287
+ Get items of active picker
1288
+
1289
+ Return ~
1290
+ `(table|nil)` Picker items or `nil` if no active picker.
1291
+
1292
+ See also ~
1293
+ |MiniPick.set_picker_items()| and |MiniPick.set_picker_items_from_cli()|
1294
+
1295
+ ------------------------------------------------------------------------------
1296
+ *MiniPick.get_picker_stritems()*
1297
+ `MiniPick.get_picker_stritems`()
1298
+ Get stritems of active picker
1299
+
1300
+ Return ~
1301
+ `(table|nil)` Picker stritems (|MiniPick-source.items-stritems|) or `nil` if
1302
+ no active picker.
1303
+
1304
+ See also ~
1305
+ |MiniPick.set_picker_items()| and |MiniPick.set_picker_items_from_cli()|
1306
+
1307
+ ------------------------------------------------------------------------------
1308
+ *MiniPick.get_picker_matches()*
1309
+ `MiniPick.get_picker_matches`()
1310
+ Get matches of active picker
1311
+
1312
+ Return ~
1313
+ `(table|nil)` Picker matches or `nil` if no active picker. Matches is a table
1314
+ with the following fields:
1315
+ - <all> `(table|nil)` - all currently matched items.
1316
+ - <all_inds> `(table|nil)` - indexes of all currently matched items.
1317
+ - <current> `(any)` - current matched item.
1318
+ - <current_ind> `(number|nil)` - index of current matched item.
1319
+ - <marked> `(table|nil)` - marked items.
1320
+ - <marked_inds> `(table|nil)` - indexes of marked items.
1321
+ - <shown> `(table|nil)` - shown items (from top to bottom).
1322
+ - <shown_inds> `(table|nil)` - indexes of shown items (from top to bottom).
1323
+
1324
+ See also ~
1325
+ |MiniPick.set_picker_match_inds()|
1326
+
1327
+ ------------------------------------------------------------------------------
1328
+ *MiniPick.get_picker_opts()*
1329
+ `MiniPick.get_picker_opts`()
1330
+ Get config of active picker
1331
+
1332
+ Return ~
1333
+ `(table|nil)` Picker config (`opts` table of |MiniPick.start()|) or `nil` if
1334
+ no active picker.
1335
+
1336
+ See also ~
1337
+ |MiniPick.set_picker_opts()|
1338
+
1339
+ ------------------------------------------------------------------------------
1340
+ *MiniPick.get_picker_state()*
1341
+ `MiniPick.get_picker_state`()
1342
+ Get state data of active picker
1343
+
1344
+ Return ~
1345
+ `(table|nil)` Table with picker state data or `nil` if no active picker.
1346
+ State data is a table with the following fields:
1347
+ - <buffers> `(table)` - table with `main`, `preview`, `info` fields representing
1348
+ buffer identifier (or `nil`) for corresponding view.
1349
+ - <windows> `(table)` - table with `main` and `target` fields representing
1350
+ window identifiers for main and target windows.
1351
+ - <caret> `(number)` - caret column.
1352
+ - <is_busy> `(boolean)` - whether picker is busy with computations.
1353
+
1354
+ See also ~
1355
+ |MiniPick.set_picker_target_window()|
1356
+
1357
+ ------------------------------------------------------------------------------
1358
+ *MiniPick.get_picker_query()*
1359
+ `MiniPick.get_picker_query`()
1360
+ Get query of active picker
1361
+
1362
+ Return ~
1363
+ `(table|nil)` Array of picker query or `nil` if no active picker.
1364
+
1365
+ See also ~
1366
+ |MiniPick.set_picker_query()|
1367
+
1368
+ ------------------------------------------------------------------------------
1369
+ *MiniPick.set_picker_items()*
1370
+ `MiniPick.set_picker_items`({items}, {opts})
1371
+ Set items for active picker
1372
+
1373
+ Note: sets items asynchronously in non-blocking fashion.
1374
+
1375
+ Parameters ~
1376
+ {items} `(table)` Array of items.
1377
+ {opts} `(table|nil)` Options. Possible fields:
1378
+ - <do_match> `(boolean)` - whether to perform match after setting items.
1379
+ Default: `true`.
1380
+ - <querytick> `(number|nil)` - value of querytick (|MiniPick.get_querytick()|)
1381
+ to periodically check against when setting items. If checked querytick
1382
+ differs from supplied, no items are set.
1383
+
1384
+ See also ~
1385
+ |MiniPick.get_picker_items()| and |MiniPick.get_picker_stritems()|
1386
+
1387
+ ------------------------------------------------------------------------------
1388
+ *MiniPick.set_picker_items_from_cli()*
1389
+ `MiniPick.set_picker_items_from_cli`({command}, {opts})
1390
+ Set items for active picker based on CLI output
1391
+
1392
+ Asynchronously executes `command` and sets items to its postprocessed output.
1393
+
1394
+ Example: >lua
1395
+
1396
+ local items = vim.schedule_wrap(function()
1397
+ MiniPick.set_picker_items_from_cli({ 'echo', 'a\nb\nc' })
1398
+ end)
1399
+ MiniPick.start({ source = { items = items, name = 'Echo abc' } })
1400
+ <
1401
+ Parameters ~
1402
+ {command} `(table)` Array with (at least one) string command parts.
1403
+ {opts} `(table|nil)` Options. Possible fields:
1404
+ - <postprocess> `(function)` - callable performing postprocessing of output.
1405
+ Will be called with array of lines as input, should return array of items.
1406
+ Default: removes trailing empty lines and uses rest as string items.
1407
+ - <spawn_opts> `(table)` - `options` for |uv.spawn()|, except `args` and `stdio`.
1408
+ Note: relative `cwd` path is resolved against active picker's `cwd`.
1409
+ - <set_items_opts> `(table)` - table forwarded to |MiniPick.set_picker_items()|.
1410
+
1411
+ See also ~
1412
+ |MiniPick.get_picker_items()| and |MiniPick.get_picker_stritems()|
1413
+
1414
+ ------------------------------------------------------------------------------
1415
+ *MiniPick.set_picker_match_inds()*
1416
+ `MiniPick.set_picker_match_inds`({match_inds}, {match_type})
1417
+ Set match indexes for active picker
1418
+
1419
+ There are two intended use cases:
1420
+ - Inside custom asynchronous |MiniPick-source.match| function to set which of
1421
+ picker's stritems match the query. See |MiniPick.poke_is_picker_active()|.
1422
+ - To programmatically set current match and marked items.
1423
+ See |MiniPick.get_picker_matches()|.
1424
+
1425
+ Parameters ~
1426
+ {match_inds} `(table)` Array of numbers with picker's items indexes.
1427
+ {match_type} `(string|nil)` Type of match indexes to set. One of:
1428
+ - `"all"` (default) - indexes of items that match query.
1429
+ - `"current"` - index of current match. Only first element is used and should
1430
+ also be present among query matches.
1431
+ - `"marked"` - indexes of marked items. Values can be not among query matches.
1432
+ Will make only input indexes be marked, i.e. current marks are reset.
1433
+ Note: no `"shown"` match type as those indexes are computed automatically.
1434
+
1435
+ See also ~
1436
+ |MiniPick.get_picker_matches()|
1437
+
1438
+ ------------------------------------------------------------------------------
1439
+ *MiniPick.set_picker_opts()*
1440
+ `MiniPick.set_picker_opts`({opts})
1441
+ Set config for active picker
1442
+
1443
+ Parameters ~
1444
+ {opts} `(table)` Table overriding initial `opts` input of |MiniPick.start()|.
1445
+
1446
+ See also ~
1447
+ |MiniPick.get_picker_opts()|
1448
+
1449
+ ------------------------------------------------------------------------------
1450
+ *MiniPick.set_picker_target_window()*
1451
+ `MiniPick.set_picker_target_window`({win_id})
1452
+ Set target window for active picker
1453
+
1454
+ Parameters ~
1455
+ {win_id} `(number)` Valid window identifier to be used as the new target window.
1456
+
1457
+ See also ~
1458
+ |MiniPick.get_picker_state()|
1459
+
1460
+ ------------------------------------------------------------------------------
1461
+ *MiniPick.set_picker_query()*
1462
+ `MiniPick.set_picker_query`({query})
1463
+ Set query for active picker
1464
+
1465
+ Parameters ~
1466
+ {query} `(table)` Array of strings to be set as the new picker query.
1467
+
1468
+ See also ~
1469
+ |MiniPick.get_picker_query()|
1470
+
1471
+ ------------------------------------------------------------------------------
1472
+ *MiniPick.get_querytick()*
1473
+ `MiniPick.get_querytick`()
1474
+ Get query tick
1475
+
1476
+ Query tick is a unique query identifier. Intended to be used to detect user
1477
+ activity during and between |MiniPick.start()| calls for efficient non-blocking
1478
+ functionality. Updates after any query change, picker start and stop.
1479
+
1480
+ See |MiniPick.poke_is_picker_active()| for usage example.
1481
+
1482
+ Return ~
1483
+ `(number)` Query tick.
1484
+
1485
+ ------------------------------------------------------------------------------
1486
+ *MiniPick.is_picker_active()*
1487
+ `MiniPick.is_picker_active`()
1488
+ Check if there is an active picker
1489
+
1490
+ Return ~
1491
+ `(boolean)` Whether there is currently an active picker.
1492
+
1493
+ See also ~
1494
+ |MiniPick.poke_is_picker_active()|
1495
+
1496
+ ------------------------------------------------------------------------------
1497
+ *MiniPick.poke_is_picker_active()*
1498
+ `MiniPick.poke_is_picker_active`()
1499
+ Poke if picker is active
1500
+
1501
+ Intended to be used for non-blocking implementation of source methods.
1502
+ Returns an output of |MiniPick.is_picker_active()|, but depending on
1503
+ whether there is a coroutine running:
1504
+ - If no, return it immediately.
1505
+ - If yes, return it after `coroutine.yield()` with `coroutine.resume()`
1506
+ called "soon" by the main event-loop (see |vim.schedule()|).
1507
+
1508
+ Example of non-blocking exact `match` (as demo; can be optimized further): >lua
1509
+
1510
+ local match_nonblock = function(match_inds, stritems, query)
1511
+ local prompt, querytick = table.concat(query), MiniPick.get_querytick()
1512
+ local f = function()
1513
+ local res = {}
1514
+ for _, ind in ipairs(match_inds) do
1515
+ local should_stop = not MiniPick.poke_is_picker_active() or
1516
+ MiniPick.get_querytick() ~= querytick
1517
+ if should_stop then return end
1518
+
1519
+ if stritems[ind]:find(prompt) ~= nil then table.insert(res, ind) end
1520
+ end
1521
+
1522
+ MiniPick.set_picker_match_inds(res)
1523
+ end
1524
+
1525
+ coroutine.resume(coroutine.create(f))
1526
+ end
1527
+ <
1528
+ Return ~
1529
+ `(boolean)` Whether there is an active picker.
1530
+
1531
+ See also ~
1532
+ |MiniPick.is_picker_active()|
1533
+
1534
+
1535
+ vim:tw=78:ts=8:noet:ft=help:norl: