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.
- package/.conda/retrovim.yaml +259 -0
- package/.conda/terax.icns +0 -0
- package/.conda/terax.ico +0 -0
- package/.conda/terax.png +0 -0
- package/.github/workflows/release.yml +95 -0
- package/.gitmodules +3 -0
- package/.npm/kanata_touchcursor.js +28 -0
- package/.npm/nvim.js +26 -0
- package/.npm/yazi.js +26 -0
- package/.npm/zsh.js +17 -0
- package/.pip/kanata_touchcursor/__init__.py +28 -0
- package/.pip/nvim/__init__.py +31 -0
- package/.pip/yazi/__init__.py +31 -0
- package/.pip/zsh/__init__.py +22 -0
- package/CHANGELOG.md +26 -0
- package/LICENSE +674 -0
- package/README.md +336 -0
- package/kanata/touchcursor.kbd +164 -0
- package/nvim/init.lua +813 -0
- package/nvim/plugins/mini.nvim/.github/DISCUSSION_TEMPLATE/q-a.yml +72 -0
- package/nvim/plugins/mini.nvim/.github/ISSUE_TEMPLATE/bug-report.yml +136 -0
- package/nvim/plugins/mini.nvim/.github/ISSUE_TEMPLATE/config.yml +5 -0
- package/nvim/plugins/mini.nvim/.github/ISSUE_TEMPLATE/feature-request.yml +75 -0
- package/nvim/plugins/mini.nvim/.github/PULL_REQUEST_TEMPLATE.md +2 -0
- package/nvim/plugins/mini.nvim/.github/workflows/quality-control.yml +150 -0
- package/nvim/plugins/mini.nvim/.pre-commit-config.yaml +20 -0
- package/nvim/plugins/mini.nvim/.stylua.toml +7 -0
- package/nvim/plugins/mini.nvim/.styluaignore +1 -0
- package/nvim/plugins/mini.nvim/CHANGELOG.md +1894 -0
- package/nvim/plugins/mini.nvim/CODE_OF_CONDUCT.md +132 -0
- package/nvim/plugins/mini.nvim/CONTRIBUTING.md +331 -0
- package/nvim/plugins/mini.nvim/LICENSE +21 -0
- package/nvim/plugins/mini.nvim/MAINTAINING.md +330 -0
- package/nvim/plugins/mini.nvim/Makefile +51 -0
- package/nvim/plugins/mini.nvim/README.md +261 -0
- package/nvim/plugins/mini.nvim/TESTING.md +1011 -0
- package/nvim/plugins/mini.nvim/benchmarks/starter/README.md +35 -0
- package/nvim/plugins/mini.nvim/benchmarks/starter/benchmark.sh +56 -0
- package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_dashboard-alpha.lua +21 -0
- package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_dashboard-original.lua +17 -0
- package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_dashboard-starter.lua +18 -0
- package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_empty.lua +4 -0
- package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_starter-default.lua +7 -0
- package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_startify-alpha.lua +10 -0
- package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_startify-original.lua +7 -0
- package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_startify-starter.lua +20 -0
- package/nvim/plugins/mini.nvim/benchmarks/starter/install.sh +10 -0
- package/nvim/plugins/mini.nvim/benchmarks/starter/make_summary.py +68 -0
- package/nvim/plugins/mini.nvim/benchmarks/starter/startup-summary.md +10 -0
- package/nvim/plugins/mini.nvim/colors/miniautumn.lua +55 -0
- package/nvim/plugins/mini.nvim/colors/minicyan.lua +95 -0
- package/nvim/plugins/mini.nvim/colors/minischeme.lua +95 -0
- package/nvim/plugins/mini.nvim/colors/minispring.lua +53 -0
- package/nvim/plugins/mini.nvim/colors/minisummer.lua +49 -0
- package/nvim/plugins/mini.nvim/colors/miniwinter.lua +51 -0
- package/nvim/plugins/mini.nvim/colors/randomhue.lua +16 -0
- package/nvim/plugins/mini.nvim/doc/mini-ai.txt +889 -0
- package/nvim/plugins/mini.nvim/doc/mini-align.txt +923 -0
- package/nvim/plugins/mini.nvim/doc/mini-animate.txt +937 -0
- package/nvim/plugins/mini.nvim/doc/mini-base16.txt +285 -0
- package/nvim/plugins/mini.nvim/doc/mini-basics.txt +359 -0
- package/nvim/plugins/mini.nvim/doc/mini-bracketed.txt +622 -0
- package/nvim/plugins/mini.nvim/doc/mini-bufremove.txt +123 -0
- package/nvim/plugins/mini.nvim/doc/mini-clue.txt +760 -0
- package/nvim/plugins/mini.nvim/doc/mini-cmdline.txt +392 -0
- package/nvim/plugins/mini.nvim/doc/mini-colors.txt +880 -0
- package/nvim/plugins/mini.nvim/doc/mini-comment.txt +230 -0
- package/nvim/plugins/mini.nvim/doc/mini-completion.txt +477 -0
- package/nvim/plugins/mini.nvim/doc/mini-cursorword.txt +105 -0
- package/nvim/plugins/mini.nvim/doc/mini-deps.txt +590 -0
- package/nvim/plugins/mini.nvim/doc/mini-diff.txt +661 -0
- package/nvim/plugins/mini.nvim/doc/mini-doc.txt +434 -0
- package/nvim/plugins/mini.nvim/doc/mini-extra.txt +856 -0
- package/nvim/plugins/mini.nvim/doc/mini-files.txt +1018 -0
- package/nvim/plugins/mini.nvim/doc/mini-fuzzy.txt +160 -0
- package/nvim/plugins/mini.nvim/doc/mini-git.txt +425 -0
- package/nvim/plugins/mini.nvim/doc/mini-hipatterns.txt +489 -0
- package/nvim/plugins/mini.nvim/doc/mini-hues.txt +420 -0
- package/nvim/plugins/mini.nvim/doc/mini-icons.txt +508 -0
- package/nvim/plugins/mini.nvim/doc/mini-indentscope.txt +485 -0
- package/nvim/plugins/mini.nvim/doc/mini-input.txt +932 -0
- package/nvim/plugins/mini.nvim/doc/mini-jump.txt +202 -0
- package/nvim/plugins/mini.nvim/doc/mini-jump2d.txt +525 -0
- package/nvim/plugins/mini.nvim/doc/mini-keymap.txt +449 -0
- package/nvim/plugins/mini.nvim/doc/mini-map.txt +717 -0
- package/nvim/plugins/mini.nvim/doc/mini-misc.txt +431 -0
- package/nvim/plugins/mini.nvim/doc/mini-move.txt +181 -0
- package/nvim/plugins/mini.nvim/doc/mini-notify.txt +434 -0
- package/nvim/plugins/mini.nvim/doc/mini-nvim.txt +431 -0
- package/nvim/plugins/mini.nvim/doc/mini-operators.txt +472 -0
- package/nvim/plugins/mini.nvim/doc/mini-pairs.txt +346 -0
- package/nvim/plugins/mini.nvim/doc/mini-pick.txt +1535 -0
- package/nvim/plugins/mini.nvim/doc/mini-sessions.txt +239 -0
- package/nvim/plugins/mini.nvim/doc/mini-snippets.txt +1291 -0
- package/nvim/plugins/mini.nvim/doc/mini-splitjoin.txt +536 -0
- package/nvim/plugins/mini.nvim/doc/mini-starter.txt +618 -0
- package/nvim/plugins/mini.nvim/doc/mini-statusline.txt +361 -0
- package/nvim/plugins/mini.nvim/doc/mini-surround.txt +863 -0
- package/nvim/plugins/mini.nvim/doc/mini-tabline.txt +151 -0
- package/nvim/plugins/mini.nvim/doc/mini-test.txt +966 -0
- package/nvim/plugins/mini.nvim/doc/mini-trailspace.txt +91 -0
- package/nvim/plugins/mini.nvim/doc/mini-visits.txt +937 -0
- package/nvim/plugins/mini.nvim/logo.png +0 -0
- package/nvim/plugins/mini.nvim/lua/mini/ai.lua +2244 -0
- package/nvim/plugins/mini.nvim/lua/mini/align.lua +2076 -0
- package/nvim/plugins/mini.nvim/lua/mini/animate.lua +2127 -0
- package/nvim/plugins/mini.nvim/lua/mini/base16.lua +1752 -0
- package/nvim/plugins/mini.nvim/lua/mini/basics.lua +772 -0
- package/nvim/plugins/mini.nvim/lua/mini/bracketed.lua +2013 -0
- package/nvim/plugins/mini.nvim/lua/mini/bufremove.lua +283 -0
- package/nvim/plugins/mini.nvim/lua/mini/clue.lua +2096 -0
- package/nvim/plugins/mini.nvim/lua/mini/cmdline.lua +1182 -0
- package/nvim/plugins/mini.nvim/lua/mini/colors.lua +2483 -0
- package/nvim/plugins/mini.nvim/lua/mini/comment.lua +586 -0
- package/nvim/plugins/mini.nvim/lua/mini/completion.lua +2094 -0
- package/nvim/plugins/mini.nvim/lua/mini/cursorword.lua +311 -0
- package/nvim/plugins/mini.nvim/lua/mini/deps.lua +1660 -0
- package/nvim/plugins/mini.nvim/lua/mini/diff.lua +1938 -0
- package/nvim/plugins/mini.nvim/lua/mini/doc.lua +1371 -0
- package/nvim/plugins/mini.nvim/lua/mini/extra.lua +2290 -0
- package/nvim/plugins/mini.nvim/lua/mini/files.lua +3145 -0
- package/nvim/plugins/mini.nvim/lua/mini/fuzzy.lua +356 -0
- package/nvim/plugins/mini.nvim/lua/mini/git.lua +1737 -0
- package/nvim/plugins/mini.nvim/lua/mini/hipatterns.lua +1042 -0
- package/nvim/plugins/mini.nvim/lua/mini/hues.lua +2088 -0
- package/nvim/plugins/mini.nvim/lua/mini/icons.lua +2254 -0
- package/nvim/plugins/mini.nvim/lua/mini/indentscope.lua +1158 -0
- package/nvim/plugins/mini.nvim/lua/mini/init.lua +427 -0
- package/nvim/plugins/mini.nvim/lua/mini/input.lua +2183 -0
- package/nvim/plugins/mini.nvim/lua/mini/jump.lua +609 -0
- package/nvim/plugins/mini.nvim/lua/mini/jump2d.lua +1244 -0
- package/nvim/plugins/mini.nvim/lua/mini/keymap.lua +880 -0
- package/nvim/plugins/mini.nvim/lua/mini/map.lua +1709 -0
- package/nvim/plugins/mini.nvim/lua/mini/misc.lua +969 -0
- package/nvim/plugins/mini.nvim/lua/mini/move.lua +509 -0
- package/nvim/plugins/mini.nvim/lua/mini/notify.lua +938 -0
- package/nvim/plugins/mini.nvim/lua/mini/operators.lua +1349 -0
- package/nvim/plugins/mini.nvim/lua/mini/pairs.lua +657 -0
- package/nvim/plugins/mini.nvim/lua/mini/pick.lua +3876 -0
- package/nvim/plugins/mini.nvim/lua/mini/sessions.lua +689 -0
- package/nvim/plugins/mini.nvim/lua/mini/snippets.lua +2828 -0
- package/nvim/plugins/mini.nvim/lua/mini/splitjoin.lua +1132 -0
- package/nvim/plugins/mini.nvim/lua/mini/starter.lua +1599 -0
- package/nvim/plugins/mini.nvim/lua/mini/statusline.lua +686 -0
- package/nvim/plugins/mini.nvim/lua/mini/surround.lua +2388 -0
- package/nvim/plugins/mini.nvim/lua/mini/tabline.lua +564 -0
- package/nvim/plugins/mini.nvim/lua/mini/test.lua +2516 -0
- package/nvim/plugins/mini.nvim/lua/mini/trailspace.lua +215 -0
- package/nvim/plugins/mini.nvim/lua/mini/visits.lua +1577 -0
- package/nvim/plugins/mini.nvim/readmes/mini-ai.md +190 -0
- package/nvim/plugins/mini.nvim/readmes/mini-align.md +203 -0
- package/nvim/plugins/mini.nvim/readmes/mini-animate.md +214 -0
- package/nvim/plugins/mini.nvim/readmes/mini-base16.md +198 -0
- package/nvim/plugins/mini.nvim/readmes/mini-basics.md +184 -0
- package/nvim/plugins/mini.nvim/readmes/mini-bracketed.md +193 -0
- package/nvim/plugins/mini.nvim/readmes/mini-bufremove.md +139 -0
- package/nvim/plugins/mini.nvim/readmes/mini-clue.md +260 -0
- package/nvim/plugins/mini.nvim/readmes/mini-cmdline.md +183 -0
- package/nvim/plugins/mini.nvim/readmes/mini-colors.md +169 -0
- package/nvim/plugins/mini.nvim/readmes/mini-comment.md +183 -0
- package/nvim/plugins/mini.nvim/readmes/mini-completion.md +217 -0
- package/nvim/plugins/mini.nvim/readmes/mini-cursorword.md +137 -0
- package/nvim/plugins/mini.nvim/readmes/mini-deps.md +271 -0
- package/nvim/plugins/mini.nvim/readmes/mini-diff.md +289 -0
- package/nvim/plugins/mini.nvim/readmes/mini-doc.md +198 -0
- package/nvim/plugins/mini.nvim/readmes/mini-extra.md +158 -0
- package/nvim/plugins/mini.nvim/readmes/mini-files.md +247 -0
- package/nvim/plugins/mini.nvim/readmes/mini-fuzzy.md +134 -0
- package/nvim/plugins/mini.nvim/readmes/mini-git.md +168 -0
- package/nvim/plugins/mini.nvim/readmes/mini-hipatterns.md +176 -0
- package/nvim/plugins/mini.nvim/readmes/mini-hues.md +285 -0
- package/nvim/plugins/mini.nvim/readmes/mini-icons.md +183 -0
- package/nvim/plugins/mini.nvim/readmes/mini-indentscope.md +191 -0
- package/nvim/plugins/mini.nvim/readmes/mini-input.md +163 -0
- package/nvim/plugins/mini.nvim/readmes/mini-jump.md +161 -0
- package/nvim/plugins/mini.nvim/readmes/mini-jump2d.md +197 -0
- package/nvim/plugins/mini.nvim/readmes/mini-keymap.md +205 -0
- package/nvim/plugins/mini.nvim/readmes/mini-map.md +191 -0
- package/nvim/plugins/mini.nvim/readmes/mini-misc.md +145 -0
- package/nvim/plugins/mini.nvim/readmes/mini-move.md +163 -0
- package/nvim/plugins/mini.nvim/readmes/mini-notify.md +175 -0
- package/nvim/plugins/mini.nvim/readmes/mini-operators.md +193 -0
- package/nvim/plugins/mini.nvim/readmes/mini-pairs.md +158 -0
- package/nvim/plugins/mini.nvim/readmes/mini-pick.md +340 -0
- package/nvim/plugins/mini.nvim/readmes/mini-sessions.md +164 -0
- package/nvim/plugins/mini.nvim/readmes/mini-snippets.md +373 -0
- package/nvim/plugins/mini.nvim/readmes/mini-splitjoin.md +194 -0
- package/nvim/plugins/mini.nvim/readmes/mini-starter.md +176 -0
- package/nvim/plugins/mini.nvim/readmes/mini-statusline.md +155 -0
- package/nvim/plugins/mini.nvim/readmes/mini-surround.md +190 -0
- package/nvim/plugins/mini.nvim/readmes/mini-tabline.md +156 -0
- package/nvim/plugins/mini.nvim/readmes/mini-test.md +175 -0
- package/nvim/plugins/mini.nvim/readmes/mini-trailspace.md +137 -0
- package/nvim/plugins/mini.nvim/readmes/mini-visits.md +243 -0
- package/nvim/plugins/mini.nvim/scripts/dual_log.sh +13 -0
- package/nvim/plugins/mini.nvim/scripts/dual_push.sh +15 -0
- package/nvim/plugins/mini.nvim/scripts/dual_release.sh +102 -0
- package/nvim/plugins/mini.nvim/scripts/dual_sync.sh +115 -0
- package/nvim/plugins/mini.nvim/scripts/init-deps-example.lua +59 -0
- package/nvim/plugins/mini.nvim/scripts/lint-filename-length.sh +16 -0
- package/nvim/plugins/mini.nvim/scripts/lintcommit-ci.sh +18 -0
- package/nvim/plugins/mini.nvim/scripts/lintcommit.lua +393 -0
- package/nvim/plugins/mini.nvim/scripts/minidoc.lua +57 -0
- package/nvim/plugins/mini.nvim/scripts/minimal_init.lua +28 -0
- package/nvim/plugins/mini.nvim/scripts/minitest.lua +4 -0
- package/package.json +16 -0
- package/pyproject.toml +43 -0
- package/yazi/init.lua +12 -0
- package/yazi/keymap.toml +114 -0
- package/yazi/lesskey +5 -0
- package/yazi/plugins/bookmarks.yazi/main.lua +86 -0
- package/yazi/plugins/cd-git-root.yazi/main.lua +31 -0
- package/yazi/plugins/smart-enter.yazi/main.lua +11 -0
- package/yazi/theme.toml +26 -0
- package/yazi/yazi.toml +15 -0
- package/zsh/.zshrc +145 -0
- package/zsh/starship.toml +20 -0
- package/zsh/zsh-patina.toml +2 -0
|
@@ -0,0 +1,932 @@
|
|
|
1
|
+
*mini.input* Get user input
|
|
2
|
+
|
|
3
|
+
MIT License Copyright (c) 2026 Evgeni Chasnovski
|
|
4
|
+
|
|
5
|
+
------------------------------------------------------------------------------
|
|
6
|
+
*MiniInput*
|
|
7
|
+
Features:
|
|
8
|
+
|
|
9
|
+
- Get user input with fully customizable key and view handling.
|
|
10
|
+
|
|
11
|
+
- Built-in configurable views as floating window, statusline/tabline/winbar,
|
|
12
|
+
virtual line/text.
|
|
13
|
+
|
|
14
|
+
- Implementation is non-blocking but waits to return the input. It also works
|
|
15
|
+
in any mode without requiring mode change. See |MiniInput-lifecycle|.
|
|
16
|
+
|
|
17
|
+
- |vim.ui.input()| implementation. To adjust, use |MiniInput.ui_input()| or
|
|
18
|
+
save-restore `vim.ui.input` manually after calling |MiniInput.setup()|.
|
|
19
|
+
|
|
20
|
+
Sources with more details:
|
|
21
|
+
- |MiniInput.get()|
|
|
22
|
+
- |MiniInput.default_key()|
|
|
23
|
+
- |MiniInput-state|
|
|
24
|
+
- |MiniInput-examples|
|
|
25
|
+
- |MiniInput-in-other-plugins| (for plugin authors)
|
|
26
|
+
|
|
27
|
+
# Setup ~
|
|
28
|
+
|
|
29
|
+
This module needs a setup with `require('mini.input').setup({})` (replace `{}`
|
|
30
|
+
with your `config` table). It will create global Lua table `MiniInput` which
|
|
31
|
+
you can use for scripting or manually (with `:lua MiniInput.*`).
|
|
32
|
+
|
|
33
|
+
See |MiniInput.config| for `config` structure and default values.
|
|
34
|
+
|
|
35
|
+
You can override runtime config settings locally to buffer inside
|
|
36
|
+
`vim.b.miniinput_config` which should have same structure as
|
|
37
|
+
`MiniInput.config`. See |mini.nvim-buffer-local-config| for more details.
|
|
38
|
+
|
|
39
|
+
# Comparisons ~
|
|
40
|
+
|
|
41
|
+
- [folke/snacks.nvim#input](https://github.com/folke/snacks.nvim):
|
|
42
|
+
- Both provide |vim.ui.input()| implementation.
|
|
43
|
+
- Has asynchronous implementation (i.e. does not wait for user to finish
|
|
44
|
+
input), while this module has synchronous non-blocking implementation.
|
|
45
|
+
- Uses floating window and forced Insert mode. This module allows more
|
|
46
|
+
view customizations and can be used in any mode without interruptions.
|
|
47
|
+
|
|
48
|
+
- |input()|:
|
|
49
|
+
- Both are synchronous.
|
|
50
|
+
- Both allow custom highlight and completion.
|
|
51
|
+
- This module also allows supplying input scope and visibility,
|
|
52
|
+
customizing keys and view.
|
|
53
|
+
|
|
54
|
+
# Highlight groups ~
|
|
55
|
+
*MiniInput-hl-groups*
|
|
56
|
+
|
|
57
|
+
- `MiniInputAdded` - added text during completion navigation.
|
|
58
|
+
- `MiniInputBorder` - border of a |MiniInput.gen_view.floatwin()| handler.
|
|
59
|
+
- `MiniInputCaret` - caret symbol shown in a prompt area.
|
|
60
|
+
- `MiniInputHide` - input is hidden, usually used instead of `MiniInputPrompt`.
|
|
61
|
+
- `MiniInputHint` - hints shown during completion navigation.
|
|
62
|
+
- `MiniInputNormal` - basic foreground/background.
|
|
63
|
+
- `MiniInputPrompt` - input prompt (intention of the input).
|
|
64
|
+
- `MiniInputSpecial` - special keys (like literal `\t`, `\n`, etc.) in input.
|
|
65
|
+
|
|
66
|
+
# Using in other plugins ~
|
|
67
|
+
*MiniInput-in-other-plugins*
|
|
68
|
+
|
|
69
|
+
- Prefer using |vim.ui.input()| for more user coverage. Use |MiniInput.get()|
|
|
70
|
+
only when getting input synchronously is absolutely necessary.
|
|
71
|
+
|
|
72
|
+
- Perform a `_G.MiniInput ~= nil` check before using any feature. This ensures
|
|
73
|
+
that user explicitly set up the module.
|
|
74
|
+
|
|
75
|
+
------------------------------------------------------------------------------
|
|
76
|
+
*MiniInput-state*
|
|
77
|
+
Information about the state of the input. It is passed as a handler argument.
|
|
78
|
+
Use |MiniInput.get_state()| to get information about the current state (if any).
|
|
79
|
+
A table with the following fields:
|
|
80
|
+
|
|
81
|
+
- <caret> `(number)` - character (not byte) index at which to modify input.
|
|
82
|
+
Should be from 1 (prepend input) to "input width plus 1" (append input).
|
|
83
|
+
|
|
84
|
+
- <complete> `(table|nil)` - information about active completion navigation.
|
|
85
|
+
If present, it means that completion navigation is in action.
|
|
86
|
+
Its fields describe the state of navigation:
|
|
87
|
+
- <base> `(string)` - reference text to the left of caret at the start
|
|
88
|
+
of completion. Used to compute candidates. Can be empty string.
|
|
89
|
+
- <id> `(number)` - identifier of current completion item. Can be zero to
|
|
90
|
+
mean that the base is shown. If not zero, must mean that a `items[id]`
|
|
91
|
+
candidate is now shown to the left of caret as the part of the input.
|
|
92
|
+
- <items> `(table)` - string array of completion candidates. May be empty.
|
|
93
|
+
Are intended to fully replace <base>, so should contain it in any sense.
|
|
94
|
+
- <method> `(string)` - completion method. Like `"default"`, `"history"`, etc.
|
|
95
|
+
Can be `""` (empty string) to mean "default method of complete handler".
|
|
96
|
+
|
|
97
|
+
- <data> `(table)` - any information to be reused within the same input session.
|
|
98
|
+
Note: handlers should not change fields that they don't "own".
|
|
99
|
+
|
|
100
|
+
- <errmsg> `(errmsg)` - first error message caught during input process.
|
|
101
|
+
|
|
102
|
+
- <highlight> `(table|nil)` - information about current input highlighting.
|
|
103
|
+
If absent, the whole input is highlighted using `MiniInputNormal` group.
|
|
104
|
+
Should be an array of highlight ranges. They might be not ordered, overlap,
|
|
105
|
+
go outside of input width. It is up to the view handler to decide how to
|
|
106
|
+
interpret them. See |MiniInput.state_to_chunks()| for a helper.
|
|
107
|
+
Fields of a single highlight range:
|
|
108
|
+
- <from> `(number)` - character index (one-indexed) of range start.
|
|
109
|
+
- <to> `(number)` - character index (one-indexed) of range end (inclusive).
|
|
110
|
+
Should not be smaller than <from>. Can be |math.huge|.
|
|
111
|
+
- <hl> `(string)` - highlight group to use for highlighting.
|
|
112
|
+
|
|
113
|
+
- <input> `(string)` - current user input. Returned by |MiniInput.get()|.
|
|
114
|
+
|
|
115
|
+
- <opts> `(table)` - input options, same as in |MiniInput.get()|.
|
|
116
|
+
|
|
117
|
+
- <prompt> `(string)` - intention of the input. May be empty.
|
|
118
|
+
|
|
119
|
+
- <status> `(string)` - one of `"start"`, `"progress"`, `"accept"`, `"cancel"`.
|
|
120
|
+
|
|
121
|
+
------------------------------------------------------------------------------
|
|
122
|
+
*MiniInput-examples*
|
|
123
|
+
# General ~
|
|
124
|
+
|
|
125
|
+
## Initial input ~
|
|
126
|
+
|
|
127
|
+
Use `opts.init_keys` to imitate the initial state of the input: >lua
|
|
128
|
+
|
|
129
|
+
MiniInput.get({ init_keys = { 'Default' } })
|
|
130
|
+
<
|
|
131
|
+
## Custom mappings ~
|
|
132
|
+
|
|
133
|
+
Override `handlers.key` in |MiniInput.config|: >lua
|
|
134
|
+
|
|
135
|
+
local key_handler = function(state, key)
|
|
136
|
+
-- <C-a> - move caret to start of line
|
|
137
|
+
if key == '\1' then
|
|
138
|
+
state.caret = 1
|
|
139
|
+
-- <S-BS> - clear all input
|
|
140
|
+
elseif key == vim.keycode('<S-BS>') then
|
|
141
|
+
state.input, state.caret = '', 1
|
|
142
|
+
else
|
|
143
|
+
-- IMPORTANT: Fall back to processing as usual
|
|
144
|
+
return MiniInput.default_key(state, key)
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
require('mini.input').setup({ handlers = { key = key_handler } })
|
|
149
|
+
<
|
|
150
|
+
## Basic command line ~
|
|
151
|
+
|
|
152
|
+
An alternative |Command-line| with highlighting and completion: >lua
|
|
153
|
+
|
|
154
|
+
-- Construct reusable `MiniInput.get()` options
|
|
155
|
+
local cmdline_opts = { prompt = 'Command', scope = 'editor' }
|
|
156
|
+
-- - Highlight using bundled Vim tree-sitter parser and default handler
|
|
157
|
+
local highlight_vim = MiniInput.gen_highlight.treesitter('vim')
|
|
158
|
+
local highlight_cmdline = function(state)
|
|
159
|
+
state = highlight_vim(state) or state
|
|
160
|
+
return MiniInput.default_highlight(state) or state
|
|
161
|
+
end
|
|
162
|
+
cmdline_opts.handlers = { highlight = highlight_cmdline }
|
|
163
|
+
-- - Complete as if it is Command line input
|
|
164
|
+
cmdline_opts.completion = 'cmdline'
|
|
165
|
+
|
|
166
|
+
-- Create a mapping for `:`
|
|
167
|
+
local input_cmdline = function()
|
|
168
|
+
local cmd = MiniInput.get(cmdline_opts)
|
|
169
|
+
if cmd ~= nil then vim.cmd(cmd) end
|
|
170
|
+
end
|
|
171
|
+
vim.keymap.set('n', ':', input_cmdline)
|
|
172
|
+
<
|
|
173
|
+
# Handlers ~
|
|
174
|
+
|
|
175
|
+
## Key ~
|
|
176
|
+
|
|
177
|
+
Perform custom actions based on arbitrary conditions: >lua
|
|
178
|
+
|
|
179
|
+
local key_handler = function(state, key)
|
|
180
|
+
-- Adjust prompt
|
|
181
|
+
state.opts.prompt = state.opts.prompt:gsub('[?:]%s*$', '')
|
|
182
|
+
|
|
183
|
+
-- Adjust scope
|
|
184
|
+
if state.opts.prompt == 'Editor action' then
|
|
185
|
+
state.opts.scope = 'editor'
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
-- Hide from view and history
|
|
189
|
+
if state.opts.prompt:find('[Pp]assword') ~= nil then
|
|
190
|
+
state.opts.hide = true
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
-- IMPORTANT: Process as usual
|
|
194
|
+
state = MiniInput.default_key(state, key) or state
|
|
195
|
+
|
|
196
|
+
-- Auto fill and accept
|
|
197
|
+
if state.input == 'AF' then
|
|
198
|
+
state.input, state.status = 'Autofilled input', 'accept'
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
require('mini.input').setup({ handlers = { key = key_handler } })
|
|
202
|
+
<
|
|
203
|
+
## View ~
|
|
204
|
+
|
|
205
|
+
Show no view: >lua
|
|
206
|
+
|
|
207
|
+
require('mini.input').setup({ handlers = { view = function() end } })
|
|
208
|
+
<
|
|
209
|
+
Compute initial style depending on scope: >lua
|
|
210
|
+
|
|
211
|
+
local input = require('mini.input')
|
|
212
|
+
local view_virtline = input.gen_view.virtual({ style = 'above' })
|
|
213
|
+
local view_tabline = input.gen_view.uiline({ style = 'tabline' })
|
|
214
|
+
local view_winbar = input.gen_view.uiline({ style = 'winbar' })
|
|
215
|
+
local view_handler = function(state)
|
|
216
|
+
-- NOTE: does not support interactive scope change
|
|
217
|
+
local scope, view = state.opts.scope, view_tabline
|
|
218
|
+
if scope == 'buffer' or scope == 'window' then view = view_winbar end
|
|
219
|
+
if scope == 'cursor' or scope == 'line' then view = view_virtline end
|
|
220
|
+
return view(state)
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
input.setup({ handlers = { view = view_handler } })
|
|
224
|
+
<
|
|
225
|
+
Change symbols for caret and hidden input: see |MiniInput.gen_view|.
|
|
226
|
+
|
|
227
|
+
------------------------------------------------------------------------------
|
|
228
|
+
*MiniInput.setup()*
|
|
229
|
+
`MiniInput.setup`({config})
|
|
230
|
+
Module setup
|
|
231
|
+
|
|
232
|
+
Parameters ~
|
|
233
|
+
{config} `(table|nil)` Module config table. See |MiniInput.config|.
|
|
234
|
+
|
|
235
|
+
Usage ~
|
|
236
|
+
>lua
|
|
237
|
+
require('mini.input').setup() -- use default config
|
|
238
|
+
-- OR
|
|
239
|
+
require('mini.input').setup({}) -- replace {} with your config table
|
|
240
|
+
<
|
|
241
|
+
------------------------------------------------------------------------------
|
|
242
|
+
*MiniInput.config*
|
|
243
|
+
`MiniInput.config`
|
|
244
|
+
Defaults ~
|
|
245
|
+
>lua
|
|
246
|
+
MiniInput.config = {
|
|
247
|
+
-- Functions that control input lifecycle
|
|
248
|
+
handlers = {
|
|
249
|
+
-- Compute completion candidates
|
|
250
|
+
complete = nil,
|
|
251
|
+
|
|
252
|
+
-- Compute highlighting of current input
|
|
253
|
+
highlight = nil,
|
|
254
|
+
|
|
255
|
+
-- Handle input start, every key press, and input end
|
|
256
|
+
key = nil,
|
|
257
|
+
|
|
258
|
+
-- Show current input state
|
|
259
|
+
view = nil,
|
|
260
|
+
},
|
|
261
|
+
|
|
262
|
+
-- Default input scope: cursor/line/buffer/window/tabpage/editor/project
|
|
263
|
+
scope = 'editor',
|
|
264
|
+
}
|
|
265
|
+
<
|
|
266
|
+
# Handlers ~
|
|
267
|
+
*MiniInput.config.handlers*
|
|
268
|
+
|
|
269
|
+
`config.handlers` defines functions that are applied during |MiniInput-lifecycle|.
|
|
270
|
+
Every handler takes |MiniInput-state| as the first argument and is expected to
|
|
271
|
+
either modify it in place or return a new state table.
|
|
272
|
+
|
|
273
|
+
Use |MiniInput.apply_handler()| to apply a handler for a given |MiniInput-state|.
|
|
274
|
+
They can be set up as part of the config (will be used as default) or passed
|
|
275
|
+
directly as a part of |MiniInput.get()| call.
|
|
276
|
+
|
|
277
|
+
## Complete ~
|
|
278
|
+
|
|
279
|
+
`handlers.complete` is a handler intended to compute completion suggestions.
|
|
280
|
+
Takes |MiniInput-state| and `method` as arguments and is expected to modify
|
|
281
|
+
<complete> field. Default: |MiniInput.default_complete()|.
|
|
282
|
+
|
|
283
|
+
Only `complete.base` and `complete.items` are expected to be set by a complete
|
|
284
|
+
handler. Setting and modifying other fields (`complete.id` and `complete.method`)
|
|
285
|
+
is done in other handlers and as part of |MiniInput.apply_handler()|. Actually
|
|
286
|
+
showing completion information is up to the view handler.
|
|
287
|
+
|
|
288
|
+
This handler is usually applied manually inside a key handler via using
|
|
289
|
+
`MiniInput.apply_handler(state, 'complete', method)`. Like, for example,
|
|
290
|
+
in |MiniInput.default_key()| after <Tab> or <Up>.
|
|
291
|
+
|
|
292
|
+
Here is an example of a simple demo complete handler: >lua
|
|
293
|
+
|
|
294
|
+
local complete_handler = function(state, method)
|
|
295
|
+
if method == '' or method == 'xy' then
|
|
296
|
+
local text = vim.fn.strcharpart(state.input, 0, state.caret - 1)
|
|
297
|
+
local base = text:match('%S*$')
|
|
298
|
+
state.complete = { base = base, items = { base .. 'x', base .. 'y' } }
|
|
299
|
+
return
|
|
300
|
+
end
|
|
301
|
+
return MiniInput.default_complete(state, method)
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
require('mini.input').setup({ handlers = { complete = complete_handler } })
|
|
305
|
+
<
|
|
306
|
+
## Key ~
|
|
307
|
+
|
|
308
|
+
`handlers.key` is a handler intended to process every user key press.
|
|
309
|
+
Takes |MiniInput-state| and `key` as arguments. Argument `key` represents a key
|
|
310
|
+
that needs to be processed: a string if from the user input or `nil` if input
|
|
311
|
+
needs to be set up, refreshed, or torn down. Default: |MiniInput.default_key()|.
|
|
312
|
+
|
|
313
|
+
A string `key` can be two kinds:
|
|
314
|
+
- Forwarded from |getcharstr()| verbatim as a result of interactive key press.
|
|
315
|
+
Meaning it will be in escaped form and not as a |key-notation|: i.e. `"\r"`
|
|
316
|
+
and not `"<CR>"`. It also means that all kinds of combos (`<M-...>`, `<C-S-...>`),
|
|
317
|
+
mouse clicks, and wheel scrolls are also forwarded to key handler.
|
|
318
|
+
- Any string as part of `opts.init_keys` in |MiniInput.get()|. If a string
|
|
319
|
+
doesn't look like it came from |getcharstr()|, it is usually a good idea
|
|
320
|
+
to insert this string at caret as is.
|
|
321
|
+
|
|
322
|
+
The suggested overall approach for custom key handler is "if `key` is special -
|
|
323
|
+
act on it, if can be used in the input - insert at caret, ignore otherwise".
|
|
324
|
+
It is also important to never change the current mode (as in |vim-modes|)
|
|
325
|
+
for |MiniInput.get()| to work as expected.
|
|
326
|
+
|
|
327
|
+
Here is an example of a basic custom key handler: >lua
|
|
328
|
+
|
|
329
|
+
local custom_actions = {
|
|
330
|
+
[vim.keycode('<Left>')] = function(state)
|
|
331
|
+
state.caret = math.max(state.caret - 1, 1)
|
|
332
|
+
end,
|
|
333
|
+
[vim.keycode('<Right>')] = function(state)
|
|
334
|
+
local input_width = vim.fn.strchars(state.input)
|
|
335
|
+
state.caret = math.min(state.caret + 1, input_width + 1)
|
|
336
|
+
end,
|
|
337
|
+
[vim.keycode('<CR>')] = function(state) state.status = 'accept' end,
|
|
338
|
+
[vim.keycode('<Esc>')] = function(state) state.status = 'cancel' end,
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
local key_handler = function(state, key)
|
|
342
|
+
-- No need for special setup or teardown
|
|
343
|
+
if key == nil then return end
|
|
344
|
+
|
|
345
|
+
-- If key is special - act on it
|
|
346
|
+
if custom_actions[key] then return custom_actions[key](state) end
|
|
347
|
+
|
|
348
|
+
-- If key is not printable - do nothing
|
|
349
|
+
if vim.fn.match(key, '^[[:print:]]\\+$') < 0 then return end
|
|
350
|
+
|
|
351
|
+
-- Insert at caret
|
|
352
|
+
local caret, input = state.caret, state.input
|
|
353
|
+
local before_caret = vim.fn.strcharpart(input, 0, caret - 1)
|
|
354
|
+
local after_caret = vim.fn.strcharpart(input, caret - 1)
|
|
355
|
+
state.input = before_caret .. key .. after_caret
|
|
356
|
+
state.caret = caret + vim.fn.strchars(key)
|
|
357
|
+
|
|
358
|
+
-- No need to return anything as `state` is modified in place
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
require('mini.input').setup({ handlers = { key = key_handler } })
|
|
362
|
+
<
|
|
363
|
+
## Highlight ~
|
|
364
|
+
|
|
365
|
+
`handlers.highlight` is a handler intended to compute and set highlight info
|
|
366
|
+
about the current input. Takes |MiniInput-state| as the only argument and is
|
|
367
|
+
expected to modify <highlight> field. Default: |MiniInput.default_highlight()|.
|
|
368
|
+
|
|
369
|
+
See |MiniInput.gen_highlight| for built-in highlight handler generators.
|
|
370
|
+
|
|
371
|
+
It is usually a good idea to append to a <highlight> if it already exists.
|
|
372
|
+
This makes it work more robustly when combining highlights.
|
|
373
|
+
|
|
374
|
+
Here is a basic example that highlights all letters `a`: >lua
|
|
375
|
+
|
|
376
|
+
local hl_handler = function(state)
|
|
377
|
+
local highlight = {}
|
|
378
|
+
for col in string.gmatch(state.input, '()a') do
|
|
379
|
+
-- NOTE: range should use character (not byte) indexes
|
|
380
|
+
local char_col = vim.fn.charidx(state.input, col)
|
|
381
|
+
local range = { from = char_col, to = char_col, hl = 'Special' }
|
|
382
|
+
table.insert(highlight, range)
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
state.highlight = vim.list_extend(state.highlight or {}, highlight)
|
|
386
|
+
|
|
387
|
+
-- Possibly also apply default handler afterwards
|
|
388
|
+
return MiniInput.default_highlight(state)
|
|
389
|
+
end
|
|
390
|
+
|
|
391
|
+
require('mini.input').setup({ handlers = { highlight = hl_handler } })
|
|
392
|
+
<
|
|
393
|
+
## View ~
|
|
394
|
+
|
|
395
|
+
`handlers.view` is a handler intended to show the input state on screen.
|
|
396
|
+
Takes |MiniInput-state| as the only argument. Default: |MiniInput.default_view()|.
|
|
397
|
+
|
|
398
|
+
See |MiniInput.gen_view| for built-in view handler generators.
|
|
399
|
+
|
|
400
|
+
Example of view that uses |nvim_echo()| to show the input: >lua
|
|
401
|
+
|
|
402
|
+
local view_handler = function(state)
|
|
403
|
+
-- Process start and end of the input lifecycle
|
|
404
|
+
local is_start = state.status == 'start'
|
|
405
|
+
local is_end = state.status == 'accept' or state.status == 'cancel'
|
|
406
|
+
if is_start or is_end then vim.cmd('mode') end
|
|
407
|
+
if is_end then return end
|
|
408
|
+
|
|
409
|
+
-- Compute text-hl chunks that fit and show them
|
|
410
|
+
local chunks = MiniInput.state_to_chunks(state, vim.v.echospace)
|
|
411
|
+
vim.api.nvim_echo(chunks, false, {})
|
|
412
|
+
end
|
|
413
|
+
|
|
414
|
+
require('mini.input').setup({ handlers = { view = view_handler } })
|
|
415
|
+
<
|
|
416
|
+
# Scope ~
|
|
417
|
+
|
|
418
|
+
`config.scope` is a string that defines an input scope. It is meant as an extra
|
|
419
|
+
information for handlers to tweak their behavior (`view` style, etc.). Possible
|
|
420
|
+
values: `"cursor"`, `"line"`, `"buffer"`, `"window"`, `"tabpage"`, `"editor"`, `"project"`.
|
|
421
|
+
|
|
422
|
+
------------------------------------------------------------------------------
|
|
423
|
+
*MiniInput.get()*
|
|
424
|
+
`MiniInput.get`({opts})
|
|
425
|
+
Get input from the user
|
|
426
|
+
|
|
427
|
+
# Lifecycle ~
|
|
428
|
+
*MiniInput-lifecycle*
|
|
429
|
+
|
|
430
|
+
This module implements custom lifecycle to interact with the user. It starts
|
|
431
|
+
when calling |MiniInput.get()| and ends when a value is returned.
|
|
432
|
+
Only one active input is allowed simultaneously.
|
|
433
|
+
|
|
434
|
+
The basic cycle unit is a step that processes a `key` (string or `nil`). It is
|
|
435
|
+
done by calling relevant handlers in order: key handler with `key` as a second
|
|
436
|
+
argument, highlight handler, view handler. |MiniInput.apply_handler()| is used
|
|
437
|
+
to apply each handler and the output of one is used as the input for the next.
|
|
438
|
+
|
|
439
|
+
During a step some state fields are automatically removed:
|
|
440
|
+
- <highlight> is removed before applying a key handler to always have the most
|
|
441
|
+
up to date highlighting.
|
|
442
|
+
- <complete> is removed if it was not changed after applying a key handler but
|
|
443
|
+
something else in the state besides <highlight> did change. This is meant as
|
|
444
|
+
an automatic stop of completion when it is not advancing.
|
|
445
|
+
|
|
446
|
+
If a step sets an ending state <status> (i.e. `"accept"` or `"cancel"`), the input
|
|
447
|
+
is finished by extra finishing step (see below).
|
|
448
|
+
|
|
449
|
+
The order of operations is as follows:
|
|
450
|
+
- Create initial |MiniInput-state| based on the input `opts`, with defaults
|
|
451
|
+
inferred from |MiniInput.config|, and `vim.b.miniinput_config`.
|
|
452
|
+
- Set <status> to `"start"`.
|
|
453
|
+
- Advance one step with `key=nil`. This is meant as a "setup" step for handlers.
|
|
454
|
+
- Set <status> to `"progress"`.
|
|
455
|
+
- Process `opts.init_keys` one item per step with `key` set to the string item.
|
|
456
|
+
- Wait for user to press a key (via |getcharstr()|). The key string (in escaped
|
|
457
|
+
form and not as a |key-notation|; i.e. `"\r"` and not `"<CR>"`) is then used
|
|
458
|
+
to advance a step. Note: <C-c> is hard coded to cancel the input.
|
|
459
|
+
- Repeat previous step until the ending <status> (`"accept"` or `"cancel"`).
|
|
460
|
+
- Finish the input:
|
|
461
|
+
- Perform a "teardown" step with `key=nil`.
|
|
462
|
+
- If <errmsg> is set, throw an |error()|.
|
|
463
|
+
- If input is accepted (even if empty) and not hidden, add <input> to
|
|
464
|
+
the history. Get the whole history with |MiniInput.get_history()|.
|
|
465
|
+
- Return <input> if <status> is `"accept"`, `nil` otherwise.
|
|
466
|
+
|
|
467
|
+
Parameters ~
|
|
468
|
+
{opts} `(table|nil)` Options. Possible fields:
|
|
469
|
+
- <completion> `(string)` - completion method. Default: `''` to use default
|
|
470
|
+
completion method of the `complete` handler.
|
|
471
|
+
- <handlers> `(table)` - same as in |MiniInput.config.handlers|, used only for
|
|
472
|
+
the duration of the current input.
|
|
473
|
+
- <hide> `(boolean)` - whether input should be hidden. Default: `false`.
|
|
474
|
+
Note: this does not guarantee a total security of the input, only that
|
|
475
|
+
the typed characters are expected to not be shown on screen and not added
|
|
476
|
+
to the history. If set:
|
|
477
|
+
- The `view` handler is expected to not directly show current input.
|
|
478
|
+
Like replace characters with pre-defined string or fully not show.
|
|
479
|
+
- The `complete` and `highlight` handlers are not called.
|
|
480
|
+
- Accepted input will not be added to the history.
|
|
481
|
+
- <init_keys> `(table)` - array of string keys that are emulated before asking
|
|
482
|
+
for the user input. Using values that can be an output of |getcharstr()|
|
|
483
|
+
should be preferred, but a key handler should work with any string.
|
|
484
|
+
Default: `{}`.
|
|
485
|
+
- <prompt> `(string)` - intention of the input, same as in |input()|.
|
|
486
|
+
Default: `"Input"`.
|
|
487
|
+
- <scope> `(string)` - same as in |MiniInput.config|. Default: the value from
|
|
488
|
+
`MiniInput.config` with some hard coded exceptions (on Neovim<0.12.3):
|
|
489
|
+
- |vim.lsp.buf.rename()| will use `"cursor"` if no `new_name` is supplied.
|
|
490
|
+
|
|
491
|
+
Return ~
|
|
492
|
+
`(string|nil)` User input (from the <input> state field) if accepted, even if
|
|
493
|
+
empty. `nil` if canceled or there was an active input.
|
|
494
|
+
|
|
495
|
+
Usage ~
|
|
496
|
+
>lua
|
|
497
|
+
local input = MiniInput.get({
|
|
498
|
+
-- Intention of the input
|
|
499
|
+
prompt = 'New value',
|
|
500
|
+
-- The input is for something at cursor
|
|
501
|
+
scope = 'cursor',
|
|
502
|
+
-- Emulate pressing `a`, `<BS>`, and `b`
|
|
503
|
+
init_keys = { 'a', vim.keycode('<BS>'), 'b' },
|
|
504
|
+
})
|
|
505
|
+
<
|
|
506
|
+
------------------------------------------------------------------------------
|
|
507
|
+
*MiniInput.ui_input()*
|
|
508
|
+
`MiniInput.ui_input`({opts}, {on_confirm})
|
|
509
|
+
A |vim.ui.input()| implementation
|
|
510
|
+
|
|
511
|
+
Function which can be used to directly override |vim.ui.input()| to use this
|
|
512
|
+
module functionality. Set automatically in |MiniInput.setup()|.
|
|
513
|
+
|
|
514
|
+
Usage ~
|
|
515
|
+
To preserve original `vim.ui.input()`: >lua
|
|
516
|
+
|
|
517
|
+
local ui_input_orig = vim.ui.input
|
|
518
|
+
require('mini.input').setup()
|
|
519
|
+
vim.ui.input = ui_input_orig
|
|
520
|
+
<
|
|
521
|
+
------------------------------------------------------------------------------
|
|
522
|
+
*MiniInput.get_state()*
|
|
523
|
+
`MiniInput.get_state`()
|
|
524
|
+
Get current input state
|
|
525
|
+
|
|
526
|
+
Return ~
|
|
527
|
+
`(table|nil)` Current |MiniInput-state| if input is active, `nil` otherwise. Notes:
|
|
528
|
+
- For hidden input (`state.opts.hide=true`), both <caret> and <input> are `nil`
|
|
529
|
+
to actually hide the input.
|
|
530
|
+
|
|
531
|
+
------------------------------------------------------------------------------
|
|
532
|
+
*MiniInput.get_history()*
|
|
533
|
+
`MiniInput.get_history`()
|
|
534
|
+
Get input history
|
|
535
|
+
|
|
536
|
+
Return ~
|
|
537
|
+
`(table)` Array with data about all previous non-hidden inputs (from earliest
|
|
538
|
+
to latest). Each element is a table with the following fields:
|
|
539
|
+
- <cwd> `(string)` - |current-directory| at the time of input's end.
|
|
540
|
+
- <input> `(string)` - input result.
|
|
541
|
+
- <prompt> `(string)` - `opts.prompt` supplied in |MiniInput.get()|.
|
|
542
|
+
- <scope> `(string)` - `opts.scope` supplied in |MiniInput.get()|.
|
|
543
|
+
|
|
544
|
+
------------------------------------------------------------------------------
|
|
545
|
+
*MiniInput.set_history()*
|
|
546
|
+
`MiniInput.set_history`({history})
|
|
547
|
+
Set input history
|
|
548
|
+
|
|
549
|
+
Parameters ~
|
|
550
|
+
{history} `(table)` Array describing all previous inputs. Same structure
|
|
551
|
+
as |MiniInput.get_history()| output.
|
|
552
|
+
|
|
553
|
+
------------------------------------------------------------------------------
|
|
554
|
+
*MiniInput.refresh()*
|
|
555
|
+
`MiniInput.refresh`()
|
|
556
|
+
Refresh active input
|
|
557
|
+
|
|
558
|
+
Performs one step of |MiniInput-lifecycle| with `key=nil`.
|
|
559
|
+
|
|
560
|
+
------------------------------------------------------------------------------
|
|
561
|
+
*MiniInput.gen_highlight*
|
|
562
|
+
`MiniInput.gen_highlight`
|
|
563
|
+
Highlight generators
|
|
564
|
+
|
|
565
|
+
This is a table with function elements. Call to actually get a view function.
|
|
566
|
+
|
|
567
|
+
------------------------------------------------------------------------------
|
|
568
|
+
*MiniInput.gen_highlight.treesitter()*
|
|
569
|
+
`MiniInput.gen_highlight.treesitter`({lang})
|
|
570
|
+
Highlight with tree-sitter
|
|
571
|
+
|
|
572
|
+
Parameters ~
|
|
573
|
+
{lang} `(string)` A language of tree-sitter parser to use.
|
|
574
|
+
|
|
575
|
+
Return ~
|
|
576
|
+
`(function)` A highlight handler. Seem |MiniInput.config.handlers|.
|
|
577
|
+
|
|
578
|
+
------------------------------------------------------------------------------
|
|
579
|
+
*MiniInput.gen_view*
|
|
580
|
+
`MiniInput.gen_view`
|
|
581
|
+
View generators
|
|
582
|
+
|
|
583
|
+
This is a table with function elements. Call to actually get a view function.
|
|
584
|
+
|
|
585
|
+
Each element accepts <style> option which fine tunes the input view.
|
|
586
|
+
With default key handler (|MiniInput.default_key()|) it can be adjusted
|
|
587
|
+
interactively by pressing <C-s>.
|
|
588
|
+
|
|
589
|
+
Each element also accepts <to_chunks> option. It is a function that takes
|
|
590
|
+
a |MiniInput-state| and `max_width` arguments and returns an array of `{ text, hl }`
|
|
591
|
+
chunks that fit into `max_width` display width (as in |strdisplaywidth()|).
|
|
592
|
+
|
|
593
|
+
This is a way to adjust how input is shown. Like caret/hide symbols, etc.
|
|
594
|
+
By default uses |MiniInput.state_to_chunks()|, which also means:
|
|
595
|
+
- All control characters (like literal `\t`, `\n`, etc.) will be translated
|
|
596
|
+
via |keytrans()|.
|
|
597
|
+
|
|
598
|
+
Example: >lua
|
|
599
|
+
|
|
600
|
+
local input = require('mini.input')
|
|
601
|
+
|
|
602
|
+
-- Adjust how state is converted to text-hl chunks
|
|
603
|
+
local to_chunks_opts = {
|
|
604
|
+
symbol_caret = '_',
|
|
605
|
+
symbol_hide = '*',
|
|
606
|
+
-- Do not include prompt and hint in `floatwin` handler
|
|
607
|
+
include_prompt = false,
|
|
608
|
+
include_hint = false,
|
|
609
|
+
}
|
|
610
|
+
local to_chunks = function(state, max_width)
|
|
611
|
+
return MiniInput.state_to_chunks(state, max_width, to_chunks_opts)
|
|
612
|
+
end
|
|
613
|
+
|
|
614
|
+
-- Supply custom `to_chunks` as an option
|
|
615
|
+
local view_opts = { to_chunks = to_chunks }
|
|
616
|
+
input.setup({ handlers = { view = input.gen_view.floatwin(view_opts) } })
|
|
617
|
+
<
|
|
618
|
+
------------------------------------------------------------------------------
|
|
619
|
+
*MiniInput.gen_view.floatwin()*
|
|
620
|
+
`MiniInput.gen_view.floatwin`({opts})
|
|
621
|
+
Floating window view
|
|
622
|
+
|
|
623
|
+
Show input inside a floating window. Prompt and completion hints are shown
|
|
624
|
+
in title and footer.
|
|
625
|
+
|
|
626
|
+
Window position and dimensions are computed based on state's <scope> and
|
|
627
|
+
`opts.style`:
|
|
628
|
+
- `scope="cursor"` is shown near the cursor. For example, `style="BL"` will
|
|
629
|
+
have bottom left corner at nearest top right cell relative to the cursor.
|
|
630
|
+
- `scope="line"` is shown near the current line. For example, `style="BL"` will
|
|
631
|
+
have bottom left corner at left side above the line.
|
|
632
|
+
- `scope="buffer"` and `scope="window"` will be shown relative to the current
|
|
633
|
+
window. For example, `style="BL"` will be shown in the bottom left corner.
|
|
634
|
+
- `scope="tabpage"`, `scope="editor"`, `scope="project"` will be shown relative to
|
|
635
|
+
the overall Neovim instance. For example, `style="BL"` will be shown in the
|
|
636
|
+
bottom left corner.
|
|
637
|
+
|
|
638
|
+
Identifiers of floating window and its buffer are stored as `floatwin_win_id`
|
|
639
|
+
and `floatwin_buf_id` in |MiniInput-state| <data> field. Floating window is
|
|
640
|
+
not focused and cursor position is not the same as caret position.
|
|
641
|
+
|
|
642
|
+
Parameters ~
|
|
643
|
+
{opts} `(table|nil)` Options. Possible fields:
|
|
644
|
+
- <adjust_config> `(function)` - function to adjust default config. Will be
|
|
645
|
+
called with two arguments: current |MiniInput-state| and a window config
|
|
646
|
+
(always with `relative="editor"` and `anchor="NW"`) computed based
|
|
647
|
+
on `opts.style`. Should return an adjusted window config.
|
|
648
|
+
Default: `function(state, config) return config end`.
|
|
649
|
+
|
|
650
|
+
- <style> `(string)` - a two character description of how to show the window.
|
|
651
|
+
Default: `"BL"`.
|
|
652
|
+
|
|
653
|
+
First character describes vertical position:
|
|
654
|
+
- `"T"` - top window border will be at scope's reference top border.
|
|
655
|
+
- `"M"` - middle between top and bottom window borders will be at the
|
|
656
|
+
middle of scope's reference top and bottom borders.
|
|
657
|
+
- `"B"` - bottom window border will be at scope's reference bottom border.
|
|
658
|
+
|
|
659
|
+
Second character describes horizontal position:
|
|
660
|
+
- `"L"` - left window border will be at scope's reference left border.
|
|
661
|
+
- `"M"` - middle between left and right window borders will be at the
|
|
662
|
+
middle of scope's reference left and right borders.
|
|
663
|
+
- `"R"` - right window border will be at scope's reference right border.
|
|
664
|
+
|
|
665
|
+
- <to_chunks> `(function)` - a function that takes |MiniInput-state| and
|
|
666
|
+
`max_width` arguments and returns an array of `{ text, hl }` chunks that fit
|
|
667
|
+
into `max_width` display width. See |MiniInput.state_to_chunks()|.
|
|
668
|
+
|
|
669
|
+
Usage ~
|
|
670
|
+
>lua
|
|
671
|
+
local input = require('mini.input')
|
|
672
|
+
|
|
673
|
+
-- Use border different from 'winborder'
|
|
674
|
+
local adjust_config = function(_, config)
|
|
675
|
+
config.border = 'double'
|
|
676
|
+
return config
|
|
677
|
+
end
|
|
678
|
+
|
|
679
|
+
-- Choose initial style based on the scope
|
|
680
|
+
local floatwin = input.gen_view.floatwin
|
|
681
|
+
local view_tm = floatwin({ style = 'TM', adjust_config = adjust_config })
|
|
682
|
+
local view_bl = floatwin({ style = 'BL', adjust_config = adjust_config })
|
|
683
|
+
local view_handler = function(state)
|
|
684
|
+
local scope, view = state.opts.scope, view_tm
|
|
685
|
+
if scope == 'cursor' or scope == 'line' then view = view_bl end
|
|
686
|
+
return view(state)
|
|
687
|
+
end
|
|
688
|
+
|
|
689
|
+
input.setup({ handlers = { view = view_handler } })
|
|
690
|
+
<
|
|
691
|
+
------------------------------------------------------------------------------
|
|
692
|
+
*MiniInput.gen_view.uiline()*
|
|
693
|
+
`MiniInput.gen_view.uiline`({opts})
|
|
694
|
+
UI line (statusline, tabline, winbar) view
|
|
695
|
+
|
|
696
|
+
Parameters ~
|
|
697
|
+
{opts} `(table|nil)` Options. Possible fields:
|
|
698
|
+
- <style> `(string)` - which UI line to use. One of `"statusline"`,
|
|
699
|
+
`"tabline"`, `"winbar"`. Default: `"statusline"`.
|
|
700
|
+
|
|
701
|
+
- <to_chunks> `(function)` - a function that takes |MiniInput-state| and
|
|
702
|
+
`max_width` arguments and returns an array of `{ text, hl }` chunks that fit
|
|
703
|
+
into `max_width` display width. See |MiniInput.state_to_chunks()|.
|
|
704
|
+
|
|
705
|
+
Usage ~
|
|
706
|
+
>lua
|
|
707
|
+
local input = require('mini.input')
|
|
708
|
+
|
|
709
|
+
-- Choose initial style based on the scope
|
|
710
|
+
local view_tabline = input.gen_view.uiline({ style = 'tabline' })
|
|
711
|
+
local view_winbar = input.gen_view.uiline({ style = 'winbar' })
|
|
712
|
+
local view_handler = function(state)
|
|
713
|
+
local scope, view = state.opts.scope, view_winbar
|
|
714
|
+
if scope == 'tabpage' or scope == 'editor' or scope == 'project' then
|
|
715
|
+
view = view_tabline
|
|
716
|
+
end
|
|
717
|
+
return view(state)
|
|
718
|
+
end
|
|
719
|
+
|
|
720
|
+
input.setup({ handlers = { view = view_handler } })
|
|
721
|
+
<
|
|
722
|
+
------------------------------------------------------------------------------
|
|
723
|
+
*MiniInput.gen_view.virtual()*
|
|
724
|
+
`MiniInput.gen_view.virtual`({opts})
|
|
725
|
+
Virtual (line, text) view
|
|
726
|
+
|
|
727
|
+
Parameters ~
|
|
728
|
+
{opts} `(table|nil)` Options. Possible fields:
|
|
729
|
+
- <style> `(string)` - how to display virtual text. One of `"above"`, `"below"`,
|
|
730
|
+
`"inline"`. Default: `"above"`.
|
|
731
|
+
|
|
732
|
+
- <to_chunks> `(function)` - a function that takes |MiniInput-state| and
|
|
733
|
+
`max_width` arguments and returns an array of `{ text, hl }` chunks that fit
|
|
734
|
+
into `max_width` display width. See |MiniInput.state_to_chunks()|.
|
|
735
|
+
|
|
736
|
+
Usage ~
|
|
737
|
+
>lua
|
|
738
|
+
-- Choose different initial style
|
|
739
|
+
local input = require('mini.input')
|
|
740
|
+
local view_handler = input.gen_view.virtual({ style = 'inline' })
|
|
741
|
+
input.setup({ handlers = { view = view_handler } })
|
|
742
|
+
<
|
|
743
|
+
------------------------------------------------------------------------------
|
|
744
|
+
*MiniInput.default_key()*
|
|
745
|
+
`MiniInput.default_key`({state}, {key}, {opts})
|
|
746
|
+
Default key handler
|
|
747
|
+
|
|
748
|
+
Emulates most of |Command-line-mode| editing (|cmdline-editing|):
|
|
749
|
+
|
|
750
|
+
- Accept: <CR>. To insert literal newline, type `<C-j>`.
|
|
751
|
+
|
|
752
|
+
- Cancel: <Esc> or <C-c>.
|
|
753
|
+
|
|
754
|
+
- Move caret:
|
|
755
|
+
- <Left>, <Right> - one character to left / right.
|
|
756
|
+
- <M-h>, <M-l> - one character to left / right.
|
|
757
|
+
- <S-Left>, <S-Right> - one word to left / right.
|
|
758
|
+
- <C-b>, <C-e> (if no completion) - to start / end of input.
|
|
759
|
+
- <Home>, <End> - to start / end of input.
|
|
760
|
+
|
|
761
|
+
- Delete:
|
|
762
|
+
- <BS> / <C-h> - to caret's left. If `opts.autopair` is enabled, also delete
|
|
763
|
+
a character to caret's right if it formed a respected character pair.
|
|
764
|
+
See "Autopair".
|
|
765
|
+
- <Del> - at caret.
|
|
766
|
+
- <C-u> - from start to caret. As |c_CTRL-U|.
|
|
767
|
+
- <C-w> - contiguous keyword or non-keyword to caret's left. As |c_CTRL-W|.
|
|
768
|
+
|
|
769
|
+
- Insert at caret:
|
|
770
|
+
- <C-k> - digraph based on the next two pressed keys. As |c_CTRL-K|.
|
|
771
|
+
- <C-r> - content of a register. As |c_CTRL-R| including support for
|
|
772
|
+
special <C-a>, <C-f>, <C-l>, <C-w> keys for a register.
|
|
773
|
+
- <C-v>, <C-q> - next key literally. As |c_CTRL-V| and |i_CTRL-V_digit|
|
|
774
|
+
(all digits must be typed in full or stopped with <C-c>).
|
|
775
|
+
- Pasting from system |clipboard| is supported for "non-streaming" paste (as
|
|
776
|
+
described in |vim.paste()|).
|
|
777
|
+
|
|
778
|
+
- Autopair (if `opts.autopair` is set) is similar to |mini.pairs|:
|
|
779
|
+
- Opening characters `(`, `[`, `{` always insert a `()`, `[]`, `{}` pair and places
|
|
780
|
+
caret inside of it.
|
|
781
|
+
- Closing characters `)`, `]`, `}` move caret to the right if there is the same
|
|
782
|
+
character to the right.
|
|
783
|
+
- Closeopen characters single+double quotes and backtick perform "close"
|
|
784
|
+
action if possible and "open" action if not.
|
|
785
|
+
- In all cases press <C-v> before special character to insert it verbatim.
|
|
786
|
+
|
|
787
|
+
- Completion:
|
|
788
|
+
- <Tab>, <S-Tab> - start with `state.opts.completion` method if not active
|
|
789
|
+
and advance through active completion (i.e. replace currently displayed
|
|
790
|
+
at caret item with the next one).
|
|
791
|
+
Note: type `<C-v><Tab>` to insert literal `\t`.
|
|
792
|
+
- <C-n>, <C-p>, <Up>, <Down> - start with `"history"` method if not active
|
|
793
|
+
and advance through active completion.
|
|
794
|
+
- <C-e> - cancel and return to initial input and caret.
|
|
795
|
+
- <C-y> - accept current candidate. Note: it will also be accepted after
|
|
796
|
+
any key that doesn't advance completion.
|
|
797
|
+
|
|
798
|
+
- Miscellaneous:
|
|
799
|
+
- <C-o> - change scope of the input. Cycles through all available ones.
|
|
800
|
+
- <C-s> - change view style. Works only with |MiniInput.gen_view| view
|
|
801
|
+
handlers. Cycles through all available ones.
|
|
802
|
+
- <C-x> - toggle hide/unhide of the input.
|
|
803
|
+
|
|
804
|
+
- Special keys (combo, mouse, but not whitespace) not listed above - ignored.
|
|
805
|
+
Anything else (even more than a single character) - inserted at caret.
|
|
806
|
+
|
|
807
|
+
Parameters ~
|
|
808
|
+
{state} `(table)` Current |MiniInput-state|.
|
|
809
|
+
{key} `(string|nil)` A key to process. Should be escaped (`"\r"`, not `"<CR>"`).
|
|
810
|
+
See |vim.keycode()|.
|
|
811
|
+
{opts} `(table|nil)` Options. Possible fields:
|
|
812
|
+
- <autopair> `(boolean)` - whether perform add autopair. Default: `false`.
|
|
813
|
+
|
|
814
|
+
------------------------------------------------------------------------------
|
|
815
|
+
*MiniInput.default_highlight()*
|
|
816
|
+
`MiniInput.default_highlight`({state})
|
|
817
|
+
Default highlight handler
|
|
818
|
+
|
|
819
|
+
During active completion highlights added (computed via |matchfuzzy()|)
|
|
820
|
+
characters with `MiniInputAdded` group.
|
|
821
|
+
|
|
822
|
+
Parameters ~
|
|
823
|
+
{state} `(table)` Current |MiniInput-state|.
|
|
824
|
+
|
|
825
|
+
------------------------------------------------------------------------------
|
|
826
|
+
*MiniInput.default_view()*
|
|
827
|
+
`MiniInput.default_view`({state})
|
|
828
|
+
Default view handler
|
|
829
|
+
|
|
830
|
+
Same as |MiniInput.gen_view.floatwin()| with default options.
|
|
831
|
+
|
|
832
|
+
Parameters ~
|
|
833
|
+
{state} `(table)` Current |MiniInput-state|.
|
|
834
|
+
|
|
835
|
+
------------------------------------------------------------------------------
|
|
836
|
+
*MiniInput.default_complete()*
|
|
837
|
+
`MiniInput.default_complete`({state}, {method}, {opts})
|
|
838
|
+
Default complete handler
|
|
839
|
+
|
|
840
|
+
Supported methods:
|
|
841
|
+
- `""` (default) - complete with buffer keywords (|'iskeyword'|) that match
|
|
842
|
+
a keyword at caret's left.
|
|
843
|
+
- `"history"` - complete with |MiniInput.get_history()| inputs that have current
|
|
844
|
+
input to caret's left as a prefix. If `opts.precise_history`, only use history
|
|
845
|
+
entries that have all info fields same as the current state. Orders from
|
|
846
|
+
earliest to latest. To initiate with the latest history match, press
|
|
847
|
+
<Up> or <C-p> with default key handler.
|
|
848
|
+
- `"cmdline"` - treat input as |Command-line| text and show completions at caret.
|
|
849
|
+
Note: as there is no |getcmdcomplpat()| variant to use outside of Command-line
|
|
850
|
+
mode, the base is inferred from |getcompletion()| output as the widest text to
|
|
851
|
+
caret's left that matches all candidates: fuzzily if |'wildoptions'| contains
|
|
852
|
+
`fuzzy`, as a prefix otherwise. If none - empty string is used. This approach
|
|
853
|
+
has limitations, but it is good enough.
|
|
854
|
+
- Every method supported by |getcompletion()|. Base is computed as the keyword
|
|
855
|
+
at caret's left.
|
|
856
|
+
|
|
857
|
+
Parameters ~
|
|
858
|
+
{state} `(table)` Current |MiniInput-state|.
|
|
859
|
+
{method} `(string)` Completion method.
|
|
860
|
+
{opts} `(table|nil)` Options. Possible fields:
|
|
861
|
+
- <precise_history> `(boolean)` - whether for `method='history'` try to match
|
|
862
|
+
only entries that have <cwd> as |current-directory|, same <scope> and
|
|
863
|
+
<prompt> as in current state. Default: `true`.
|
|
864
|
+
|
|
865
|
+
Usage ~
|
|
866
|
+
>lua
|
|
867
|
+
-- Do not match history precisely
|
|
868
|
+
local complete_opts = { precise_history = false }
|
|
869
|
+
local complete_handler = function(state, method)
|
|
870
|
+
return MiniInput.default_complete(state, method, complete_opts)
|
|
871
|
+
end
|
|
872
|
+
require('mini.input').setup({ handlers = { complete = complete_handler } })
|
|
873
|
+
<
|
|
874
|
+
------------------------------------------------------------------------------
|
|
875
|
+
*MiniInput.state_to_chunks()*
|
|
876
|
+
`MiniInput.state_to_chunks`({state}, {max_width}, {opts})
|
|
877
|
+
Convert state into text-hl chunks
|
|
878
|
+
|
|
879
|
+
- Treat `state.highlight` elements in increasing priority, i.e. later ones
|
|
880
|
+
are placed "on top" of the previous ones if they overlap.
|
|
881
|
+
- Uses |MiniInput-hl-groups|.
|
|
882
|
+
- Multiline input (i.e. with newline characters `\n`) is shown as a single line.
|
|
883
|
+
- Treats `max_width` as display width (|strdisplaywidth()|).
|
|
884
|
+
- Truncates output chunks trying to center the caret.
|
|
885
|
+
|
|
886
|
+
Parameters ~
|
|
887
|
+
{state} `(table)` A |MiniInput-state|.
|
|
888
|
+
{max_width} `(number|nil)` Maximum allowed display width. Can be |math.huge|.
|
|
889
|
+
{opts} `(table|nil)` Options. Possible fields:
|
|
890
|
+
- <keytrans> `(boolean)` - whether to translate control characters (escaped
|
|
891
|
+
version of `<C-...>`). Default: `true`.
|
|
892
|
+
- <include_prompt> `(boolean)` - whether to start chunks with state prompt.
|
|
893
|
+
Default: `true`.
|
|
894
|
+
- <include_hint> `(boolean)` - whether to show complete hint to caret's right.
|
|
895
|
+
Default: `true`.
|
|
896
|
+
- <symbol_caret> `(string)` - string to use for caret. Default: `"▏"`.
|
|
897
|
+
- <symbol_hide> `(string)` - string to use for each input character when
|
|
898
|
+
input is hidden. Default: `"•"`.
|
|
899
|
+
|
|
900
|
+
Return ~
|
|
901
|
+
`(table)` An array of text-hl chunks that fit `max_width` display width.
|
|
902
|
+
|
|
903
|
+
------------------------------------------------------------------------------
|
|
904
|
+
*MiniInput.apply_handler()*
|
|
905
|
+
`MiniInput.apply_handler`({state}, {name}, {arg})
|
|
906
|
+
Apply state's handler
|
|
907
|
+
|
|
908
|
+
Given |MiniInput-state|, apply its handler (from `state.opts.handlers`) and
|
|
909
|
+
return the modified state.
|
|
910
|
+
|
|
911
|
+
Notes:
|
|
912
|
+
- Nothing is done for highlight and complete handlers when input is hidden.
|
|
913
|
+
- Applying complete handler ensures that <complete> state field has <id> set
|
|
914
|
+
to 0 (as it assumes new completion) and <method> to the input argument
|
|
915
|
+
(empty string if there was no argument).
|
|
916
|
+
- Error during handler application is stored as <errmsg> field of output state
|
|
917
|
+
if there is an active input. It is propagated via |error()| otherwise.
|
|
918
|
+
- Handler output is validated to be a valid |MiniInput-state|. If not - return
|
|
919
|
+
input `state`. Note: it still could be changed if handler modified in place.
|
|
920
|
+
|
|
921
|
+
Parameters ~
|
|
922
|
+
{state} `(table)` A |MiniInput-state|.
|
|
923
|
+
{name} `(string)` Valid handler name.
|
|
924
|
+
{arg} `(any)` Extra handler argument: like `key` for key handler and `method`
|
|
925
|
+
for complete handler.
|
|
926
|
+
|
|
927
|
+
Return ~
|
|
928
|
+
`(table)` A |MiniInput-state| as a result of applied handler. If handler returned
|
|
929
|
+
nothing, the input `state` is returned (assumes it was modified in place).
|
|
930
|
+
|
|
931
|
+
|
|
932
|
+
vim:tw=78:ts=8:noet:ft=help:norl:
|