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,509 @@
|
|
|
1
|
+
--- *mini.move* Move any selection in any direction
|
|
2
|
+
---
|
|
3
|
+
--- MIT License Copyright (c) 2023 Evgeni Chasnovski
|
|
4
|
+
|
|
5
|
+
--- Features:
|
|
6
|
+
--- - Works in two modes:
|
|
7
|
+
--- - Visual mode. Select text (charwise with |v|, linewise with |V|, and
|
|
8
|
+
--- blockwise with |CTRL-V|) and press customizable mapping to move in
|
|
9
|
+
--- all four directions (left, right, down, up). It keeps Visual mode.
|
|
10
|
+
--- - Normal mode. Press customizable mapping to move current line in all
|
|
11
|
+
--- four directions (left, right, down, up).
|
|
12
|
+
--- - Special handling of linewise movement:
|
|
13
|
+
--- - Vertical movement gets reindented with |=|.
|
|
14
|
+
--- - Horizontal movement is improved indent/dedent with |>| / |<|.
|
|
15
|
+
--- - Cursor moves along with selection.
|
|
16
|
+
---
|
|
17
|
+
--- - Provides both mappings and Lua functions for motions. See
|
|
18
|
+
--- |MiniMove.move_selection()| and |MiniMove.move_line()|.
|
|
19
|
+
---
|
|
20
|
+
--- - Respects |v:count|. Movement mappings can be preceded by a number which
|
|
21
|
+
--- multiplies command effect.
|
|
22
|
+
---
|
|
23
|
+
--- - All consecutive moves (regardless of direction) can be undone by a single |u|.
|
|
24
|
+
---
|
|
25
|
+
--- - Respects preferred column for vertical movement. It will vertically move
|
|
26
|
+
--- selection as how cursor is moving (not strictly vertically if target
|
|
27
|
+
--- column is not present in target line).
|
|
28
|
+
---
|
|
29
|
+
--- Notes:
|
|
30
|
+
--- - Doesn't allow moving selection outside of current lines (by design).
|
|
31
|
+
---
|
|
32
|
+
--- # Setup ~
|
|
33
|
+
---
|
|
34
|
+
--- This module needs a setup with `require('mini.move').setup({})` (replace
|
|
35
|
+
--- `{}` with your `config` table). It will create global Lua table `MiniMove`
|
|
36
|
+
--- which you can use for scripting or manually (with `:lua MiniMove.*`).
|
|
37
|
+
---
|
|
38
|
+
--- See |MiniMove.config| for available config settings.
|
|
39
|
+
---
|
|
40
|
+
--- You can override runtime config settings (but not `config.mappings`) locally
|
|
41
|
+
--- to buffer inside `vim.b.minimove_config` which should have same structure
|
|
42
|
+
--- as `MiniMove.config`. See |mini.nvim-buffer-local-config| for more details.
|
|
43
|
+
---
|
|
44
|
+
--- # Comparisons ~
|
|
45
|
+
---
|
|
46
|
+
--- - [matze/vim-move](https://github.com/matze/vim-move):
|
|
47
|
+
--- - Doesn't support vertical movement of charwise and blockwise selections.
|
|
48
|
+
--- While |mini.move| does.
|
|
49
|
+
--- - Doesn't support horizontal movement of current line in favor of
|
|
50
|
+
--- horizontal movement of current character. While |mini.move| supports
|
|
51
|
+
--- horizontal movement of current line and doesn't support such movement
|
|
52
|
+
--- of current character.
|
|
53
|
+
--- - Has extra functionality for certain moves (like move by half page).
|
|
54
|
+
--- While |mini.move| does not (by design).
|
|
55
|
+
--- - [booperlv/nvim-gomove](https://github.com/booperlv/nvim-gomove):
|
|
56
|
+
--- - Doesn't support movement in charwise visual selection.
|
|
57
|
+
--- While |mini.move| does.
|
|
58
|
+
--- - Has extra functionality beyond moving text, like duplication.
|
|
59
|
+
--- While |mini.move| concentrates only on moving functionality.
|
|
60
|
+
---
|
|
61
|
+
--- # Disabling ~
|
|
62
|
+
---
|
|
63
|
+
--- To disable, set `vim.g.minimove_disable` (globally) or `vim.b.minimove_disable`
|
|
64
|
+
--- (for a buffer) to `true`. Considering high number of different scenarios
|
|
65
|
+
--- and customization intentions, writing exact rules for disabling module's
|
|
66
|
+
--- functionality is left to user. See |mini.nvim-disabling-recipes| for common
|
|
67
|
+
--- recipes.
|
|
68
|
+
---@tag MiniMove
|
|
69
|
+
|
|
70
|
+
---@alias __move_direction string One of "left", "down", "up", "right".
|
|
71
|
+
---@alias __move_opts table|nil Options. Same structure as `options` in |MiniMove.config|
|
|
72
|
+
--- (with its values as defaults) plus these allowed extra fields:
|
|
73
|
+
--- - <n_times> (number) - number of times to try to make a move.
|
|
74
|
+
--- Default: |v:count1|.
|
|
75
|
+
|
|
76
|
+
---@diagnostic disable:undefined-field
|
|
77
|
+
|
|
78
|
+
-- Module definition ==========================================================
|
|
79
|
+
local MiniMove = {}
|
|
80
|
+
local H = {}
|
|
81
|
+
|
|
82
|
+
--- Module setup
|
|
83
|
+
---
|
|
84
|
+
---@param config table|nil Module config table. See |MiniMove.config|.
|
|
85
|
+
---
|
|
86
|
+
---@usage >lua
|
|
87
|
+
--- require('mini.move').setup() -- use default config
|
|
88
|
+
--- -- OR
|
|
89
|
+
--- require('mini.move').setup({}) -- replace {} with your config table
|
|
90
|
+
--- <
|
|
91
|
+
MiniMove.setup = function(config)
|
|
92
|
+
-- TODO: Remove after Neovim=0.9 support is dropped
|
|
93
|
+
if vim.fn.has('nvim-0.10') == 0 then
|
|
94
|
+
vim.notify(
|
|
95
|
+
'(mini.move) Neovim<0.10 is soft deprecated (module works but is not supported).'
|
|
96
|
+
.. " It will be deprecated after the next 'mini.nvim' release (module might not work)."
|
|
97
|
+
.. ' Please update your Neovim version.'
|
|
98
|
+
)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
-- Export module
|
|
102
|
+
_G.MiniMove = MiniMove
|
|
103
|
+
|
|
104
|
+
-- Setup config
|
|
105
|
+
config = H.setup_config(config)
|
|
106
|
+
|
|
107
|
+
-- Apply config
|
|
108
|
+
H.apply_config(config)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
--- Defaults ~
|
|
112
|
+
---@eval return MiniDoc.afterlines_to_code(MiniDoc.current.eval_section)
|
|
113
|
+
---@text # Mappings ~
|
|
114
|
+
---
|
|
115
|
+
--- Other possible choices of mappings: >lua
|
|
116
|
+
---
|
|
117
|
+
--- -- `HJKL` for moving visual selection (overrides H, L, J in Visual mode)
|
|
118
|
+
--- require('mini.move').setup({
|
|
119
|
+
--- mappings = {
|
|
120
|
+
--- left = 'H',
|
|
121
|
+
--- right = 'L',
|
|
122
|
+
--- down = 'J',
|
|
123
|
+
--- up = 'K',
|
|
124
|
+
--- }
|
|
125
|
+
--- })
|
|
126
|
+
---
|
|
127
|
+
--- -- Shift + arrows
|
|
128
|
+
--- require('mini.move').setup({
|
|
129
|
+
--- mappings = {
|
|
130
|
+
--- left = '<S-left>',
|
|
131
|
+
--- right = '<S-right>',
|
|
132
|
+
--- down = '<S-down>',
|
|
133
|
+
--- up = '<S-up>',
|
|
134
|
+
---
|
|
135
|
+
--- line_left = '<S-left>',
|
|
136
|
+
--- line_right = '<S-right>',
|
|
137
|
+
--- line_down = '<S-down>',
|
|
138
|
+
--- line_up = '<S-up>',
|
|
139
|
+
--- }
|
|
140
|
+
--- })
|
|
141
|
+
--- <
|
|
142
|
+
MiniMove.config = {
|
|
143
|
+
-- Module mappings. Use `''` (empty string) to disable one.
|
|
144
|
+
mappings = {
|
|
145
|
+
-- Move visual selection in Visual mode. Defaults are Alt (Meta) + hjkl.
|
|
146
|
+
left = '<M-h>',
|
|
147
|
+
right = '<M-l>',
|
|
148
|
+
down = '<M-j>',
|
|
149
|
+
up = '<M-k>',
|
|
150
|
+
|
|
151
|
+
-- Move current line in Normal mode
|
|
152
|
+
line_left = '<M-h>',
|
|
153
|
+
line_right = '<M-l>',
|
|
154
|
+
line_down = '<M-j>',
|
|
155
|
+
line_up = '<M-k>',
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
-- Options which control moving behavior
|
|
159
|
+
options = {
|
|
160
|
+
-- Automatically reindent selection during linewise vertical move
|
|
161
|
+
reindent_linewise = true,
|
|
162
|
+
},
|
|
163
|
+
}
|
|
164
|
+
--minidoc_afterlines_end
|
|
165
|
+
|
|
166
|
+
-- Module functionality =======================================================
|
|
167
|
+
--- Move visually selected region in any direction within present lines
|
|
168
|
+
---
|
|
169
|
+
--- Main function powering visual selection move in Visual mode.
|
|
170
|
+
---
|
|
171
|
+
--- Notes:
|
|
172
|
+
--- - Vertical movement in linewise mode is followed up by reindent with |v_=|.
|
|
173
|
+
--- - Horizontal movement in linewise mode is same as |v_<| and |v_>|.
|
|
174
|
+
---
|
|
175
|
+
---@param direction __move_direction
|
|
176
|
+
---@param opts __move_opts
|
|
177
|
+
MiniMove.move_selection = function(direction, opts)
|
|
178
|
+
if H.is_disabled() or not vim.o.modifiable then return end
|
|
179
|
+
|
|
180
|
+
opts = vim.tbl_deep_extend('force', H.get_config().options, opts or {})
|
|
181
|
+
|
|
182
|
+
-- This could have been a one-line expression mappings, but there are issues:
|
|
183
|
+
-- - Initial yanking modifies some register. Not critical, but also not good.
|
|
184
|
+
-- - Doesn't work at movement edges (first line for `K`, etc.). See
|
|
185
|
+
-- https://github.com/vim/vim/issues/11786
|
|
186
|
+
-- - Results into each movement being a separate undo block, which is
|
|
187
|
+
-- inconvenient with several back-to-back movements.
|
|
188
|
+
local cur_mode = vim.fn.mode()
|
|
189
|
+
|
|
190
|
+
-- Act only inside visual mode
|
|
191
|
+
if not (cur_mode == 'v' or cur_mode == 'V' or cur_mode == '\22') then return end
|
|
192
|
+
|
|
193
|
+
-- Define common predicates
|
|
194
|
+
local dir_type = (direction == 'up' or direction == 'down') and 'vert' or 'hori'
|
|
195
|
+
local is_linewise = cur_mode == 'V'
|
|
196
|
+
|
|
197
|
+
-- Make early return in small buffer
|
|
198
|
+
if vim.api.nvim_buf_line_count(0) == 1 then
|
|
199
|
+
if is_linewise and dir_type == 'vert' then return end
|
|
200
|
+
if not is_linewise and vim.fn.getline(1):len() == 0 then return end
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
-- Cache useful data because it will be reset when executing commands
|
|
204
|
+
local n_times = opts.n_times or vim.v.count1
|
|
205
|
+
local ref_curpos, ref_last_col = vim.fn.getcurpos(), vim.fn.col('$')
|
|
206
|
+
local is_cursor_on_selection_start = vim.fn.line('.') < vim.fn.line('v')
|
|
207
|
+
|
|
208
|
+
-- Determine if previous action was this type of move
|
|
209
|
+
local is_moving = vim.deep_equal(H.state, H.get_move_state())
|
|
210
|
+
if not is_moving then H.curswant = nil end
|
|
211
|
+
|
|
212
|
+
-- Allow undo of consecutive moves at once (direction doesn't matter)
|
|
213
|
+
local cmd = H.make_cmd_normal(is_moving)
|
|
214
|
+
|
|
215
|
+
-- Treat horizontal linewise movement specially
|
|
216
|
+
if is_linewise and dir_type == 'hori' then
|
|
217
|
+
-- Use indentation as horizontal movement for linewise selection
|
|
218
|
+
cmd(n_times .. H.indent_keys[direction] .. 'gv')
|
|
219
|
+
|
|
220
|
+
-- Make cursor move along selection
|
|
221
|
+
H.correct_cursor_col(ref_curpos, ref_last_col)
|
|
222
|
+
|
|
223
|
+
-- Track new state to allow joining in single undo block
|
|
224
|
+
H.state = H.get_move_state()
|
|
225
|
+
|
|
226
|
+
return
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
-- Temporarily ensure possibility to put cursor just after line end.
|
|
230
|
+
-- This allows a more intuitive cursor positioning from and to end of line.
|
|
231
|
+
-- NOTE: somehow, this should be done before initial cut to take effect.
|
|
232
|
+
local cache_virtualedit = vim.o.virtualedit
|
|
233
|
+
if not cache_virtualedit:find('all') then vim.o.virtualedit = 'onemore' end
|
|
234
|
+
|
|
235
|
+
-- Cut selection while saving caching register
|
|
236
|
+
local cache_z_reg = vim.fn.getreginfo('z')
|
|
237
|
+
-- - Don't use `"zx` directly to not affect registers 1-9
|
|
238
|
+
cmd('"zygv"_x')
|
|
239
|
+
|
|
240
|
+
-- Detect edge selection: last line(s) for vertical and last character(s)
|
|
241
|
+
-- for horizontal. At this point (after cutting selection) cursor is on the
|
|
242
|
+
-- edge which can happen in two cases:
|
|
243
|
+
-- - Move second to last selection towards edge (like in 'abc' move 'b'
|
|
244
|
+
-- to right or second to last line down).
|
|
245
|
+
-- - Move edge selection away from edge (like in 'abc' move 'c' to left
|
|
246
|
+
-- or last line up).
|
|
247
|
+
-- Use condition that removed selection was further than current cursor
|
|
248
|
+
-- to distinguish between two cases.
|
|
249
|
+
local is_edge_selection_hori = dir_type == 'hori' and vim.fn.col('.') < vim.fn.col("'<")
|
|
250
|
+
local is_edge_selection_vert = dir_type == 'vert' and vim.fn.line('.') < vim.fn.line("'<")
|
|
251
|
+
local is_edge_selection = is_edge_selection_hori or is_edge_selection_vert
|
|
252
|
+
|
|
253
|
+
-- Use `p` as paste key instead of `P` in cases which might require moving
|
|
254
|
+
-- selection to place which is unreachable with `P`: right to be line end
|
|
255
|
+
-- and down to be last line. NOTE: temporary `virtualedit=onemore` solves
|
|
256
|
+
-- this only for horizontal movement, but not for vertical.
|
|
257
|
+
local can_go_overline = not is_linewise and direction == 'right'
|
|
258
|
+
local can_go_overbuf = is_linewise and direction == 'down'
|
|
259
|
+
local paste_key = (can_go_overline or can_go_overbuf) and 'p' or 'P'
|
|
260
|
+
|
|
261
|
+
-- Restore `curswant` to try move cursor to initial column (just like
|
|
262
|
+
-- default `hjkl` moves)
|
|
263
|
+
if dir_type == 'vert' then H.set_curswant(H.curswant) end
|
|
264
|
+
|
|
265
|
+
-- Possibly reduce number of moves by one to not overshoot move
|
|
266
|
+
local n = n_times - ((paste_key == 'p' or is_edge_selection) and 1 or 0)
|
|
267
|
+
|
|
268
|
+
-- Don't allow movement past last line of block selection (any part)
|
|
269
|
+
if cur_mode == '\22' and direction == 'down' and vim.fn.line('$') == vim.fn.line("'>") then n = 0 end
|
|
270
|
+
|
|
271
|
+
-- Move cursor
|
|
272
|
+
if n > 0 then cmd(n .. H.move_keys[direction]) end
|
|
273
|
+
|
|
274
|
+
-- Save curswant. Correct for one less move when using `p` as paste.
|
|
275
|
+
H.curswant = H.get_curswant() + ((direction == 'right' and paste_key == 'p') and 1 or 0)
|
|
276
|
+
|
|
277
|
+
-- Open just enough folds (but not in linewise mode, as it allows moving
|
|
278
|
+
-- past folds)
|
|
279
|
+
if not is_linewise then cmd('zv') end
|
|
280
|
+
|
|
281
|
+
-- Paste
|
|
282
|
+
cmd('"z' .. paste_key)
|
|
283
|
+
|
|
284
|
+
-- Select newly moved region. Another way is to use something like `gvhoho`
|
|
285
|
+
-- but it doesn't work well with selections spanning several lines.
|
|
286
|
+
cmd('`[1v')
|
|
287
|
+
|
|
288
|
+
-- Do extra in case of linewise selection
|
|
289
|
+
if is_linewise then
|
|
290
|
+
-- Reindent linewise selection if `=` can do that.
|
|
291
|
+
-- NOTE: this sometimes doesn't work well with folds (and probably
|
|
292
|
+
-- `foldmethod=indent`) and linewise mode because it recomputes folds after
|
|
293
|
+
-- that and the whole "move past fold" doesn't work.
|
|
294
|
+
if opts.reindent_linewise and dir_type == 'vert' and vim.o.equalprg == '' then cmd('=gv') end
|
|
295
|
+
|
|
296
|
+
-- Move cursor along the selection. NOTE: do this *after* reindent to
|
|
297
|
+
-- account for its effect.
|
|
298
|
+
-- - Ensure that cursor is on the right side of selection
|
|
299
|
+
if is_cursor_on_selection_start then cmd('o') end
|
|
300
|
+
H.correct_cursor_col(ref_curpos, ref_last_col)
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
-- Restore intermediate values
|
|
304
|
+
vim.fn.setreg('z', cache_z_reg)
|
|
305
|
+
vim.o.virtualedit = cache_virtualedit
|
|
306
|
+
|
|
307
|
+
-- Track new state to allow joining in single undo block
|
|
308
|
+
H.state = H.get_move_state()
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
--- Move current line in any direction
|
|
312
|
+
---
|
|
313
|
+
--- Main function powering current line move in Normal mode.
|
|
314
|
+
---
|
|
315
|
+
--- Notes:
|
|
316
|
+
--- - Vertical movement is followed up by reindent with |v_=|.
|
|
317
|
+
--- - Horizontal movement is almost the same as |<<| and |>>| with a different
|
|
318
|
+
--- handling of |v:count| (multiplies shift effect instead of modifying that
|
|
319
|
+
--- number of lines).
|
|
320
|
+
---
|
|
321
|
+
---@param direction __move_direction
|
|
322
|
+
---@param opts __move_opts
|
|
323
|
+
MiniMove.move_line = function(direction, opts)
|
|
324
|
+
if H.is_disabled() or not vim.o.modifiable then return end
|
|
325
|
+
if vim.api.nvim_buf_line_count(0) == 1 and (direction == 'down' or direction == 'up') then return end
|
|
326
|
+
|
|
327
|
+
opts = vim.tbl_deep_extend('force', H.get_config().options, opts or {})
|
|
328
|
+
|
|
329
|
+
-- Determine if previous action was this type of move
|
|
330
|
+
local is_moving = vim.deep_equal(H.state, H.get_move_state())
|
|
331
|
+
|
|
332
|
+
-- Allow undo of consecutive moves at once (direction doesn't matter)
|
|
333
|
+
local cmd = H.make_cmd_normal(is_moving)
|
|
334
|
+
|
|
335
|
+
-- Cache useful data because it will be reset when executing commands
|
|
336
|
+
local n_times = opts.n_times or vim.v.count1
|
|
337
|
+
local is_last_line_up = direction == 'up' and vim.fn.line('.') == vim.fn.line('$')
|
|
338
|
+
local ref_curpos, ref_last_col = vim.fn.getcurpos(), vim.fn.col('$')
|
|
339
|
+
|
|
340
|
+
if direction == 'left' or direction == 'right' then
|
|
341
|
+
-- Use indentation as horizontal movement. Explicitly call `count1` because
|
|
342
|
+
-- `<`/`>` use `v:count` to define number of lines.
|
|
343
|
+
-- Go to first non-blank at the end.
|
|
344
|
+
local key = H.indent_keys[direction]
|
|
345
|
+
cmd(string.rep(key .. key, n_times))
|
|
346
|
+
|
|
347
|
+
-- Make cursor move along selection
|
|
348
|
+
H.correct_cursor_col(ref_curpos, ref_last_col)
|
|
349
|
+
|
|
350
|
+
-- Track new state to allow joining in single undo block
|
|
351
|
+
H.state = H.get_move_state()
|
|
352
|
+
|
|
353
|
+
return
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
-- Cut current line while saving caching register
|
|
357
|
+
local cache_z_reg = vim.fn.getreginfo('z')
|
|
358
|
+
-- - Don't use `"zdd` directly to not affect registers 1-9
|
|
359
|
+
cmd('"zyy"_dd')
|
|
360
|
+
|
|
361
|
+
-- Move cursor
|
|
362
|
+
local paste_key = direction == 'up' and 'P' or 'p'
|
|
363
|
+
local n = n_times - ((paste_key == 'p' or is_last_line_up) and 1 or 0)
|
|
364
|
+
if n > 0 then cmd(n .. H.move_keys[direction]) end
|
|
365
|
+
|
|
366
|
+
-- Paste
|
|
367
|
+
cmd('"z' .. paste_key)
|
|
368
|
+
|
|
369
|
+
-- Reindent and put cursor on first non-blank
|
|
370
|
+
if opts.reindent_linewise and vim.o.equalprg == '' then cmd('==') end
|
|
371
|
+
|
|
372
|
+
-- Move cursor along the selection. NOTE: do this *after* reindent to
|
|
373
|
+
-- account for its effect.
|
|
374
|
+
H.correct_cursor_col(ref_curpos, ref_last_col)
|
|
375
|
+
|
|
376
|
+
-- Restore intermediate values
|
|
377
|
+
vim.fn.setreg('z', cache_z_reg)
|
|
378
|
+
|
|
379
|
+
-- Track new state to allow joining in single undo block
|
|
380
|
+
H.state = H.get_move_state()
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
-- Helper data ================================================================
|
|
384
|
+
-- Module default config
|
|
385
|
+
H.default_config = vim.deepcopy(MiniMove.config)
|
|
386
|
+
|
|
387
|
+
H.move_keys = { left = 'h', down = 'j', up = 'k', right = 'l' }
|
|
388
|
+
H.indent_keys = { left = '<', right = '>' }
|
|
389
|
+
|
|
390
|
+
-- Moving state used to decide when to start new undo block ...
|
|
391
|
+
H.state = {
|
|
392
|
+
-- ... on buffer change
|
|
393
|
+
buf_id = nil,
|
|
394
|
+
-- ... on text change
|
|
395
|
+
changedtick = nil,
|
|
396
|
+
-- ... on cursor move
|
|
397
|
+
cursor = nil,
|
|
398
|
+
-- ... on mode change
|
|
399
|
+
mode = nil,
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
H.curswant = nil
|
|
403
|
+
|
|
404
|
+
-- Helper functionality =======================================================
|
|
405
|
+
-- Settings -------------------------------------------------------------------
|
|
406
|
+
H.setup_config = function(config)
|
|
407
|
+
H.check_type('config', config, 'table', true)
|
|
408
|
+
config = vim.tbl_deep_extend('force', vim.deepcopy(H.default_config), config or {})
|
|
409
|
+
|
|
410
|
+
H.check_type('mappings', config.mappings, 'table')
|
|
411
|
+
H.check_type('mappings.left', config.mappings.left, 'string')
|
|
412
|
+
H.check_type('mappings.down', config.mappings.down, 'string')
|
|
413
|
+
H.check_type('mappings.up', config.mappings.up, 'string')
|
|
414
|
+
H.check_type('mappings.right', config.mappings.right, 'string')
|
|
415
|
+
H.check_type('mappings.line_left', config.mappings.line_left, 'string')
|
|
416
|
+
H.check_type('mappings.line_right', config.mappings.line_right, 'string')
|
|
417
|
+
H.check_type('mappings.line_down', config.mappings.line_down, 'string')
|
|
418
|
+
H.check_type('mappings.line_up', config.mappings.line_up, 'string')
|
|
419
|
+
|
|
420
|
+
H.check_type('options', config.options, 'table')
|
|
421
|
+
H.check_type('options.reindent_linewise', config.options.reindent_linewise, 'boolean')
|
|
422
|
+
|
|
423
|
+
return config
|
|
424
|
+
end
|
|
425
|
+
|
|
426
|
+
--stylua: ignore
|
|
427
|
+
H.apply_config = function(config)
|
|
428
|
+
MiniMove.config = config
|
|
429
|
+
|
|
430
|
+
-- Make mappings
|
|
431
|
+
local maps = config.mappings
|
|
432
|
+
|
|
433
|
+
H.map('x', maps.left, [[<Cmd>lua MiniMove.move_selection('left')<CR>]], { desc = 'Move left' })
|
|
434
|
+
H.map('x', maps.right, [[<Cmd>lua MiniMove.move_selection('right')<CR>]], { desc = 'Move right' })
|
|
435
|
+
H.map('x', maps.down, [[<Cmd>lua MiniMove.move_selection('down')<CR>]], { desc = 'Move down' })
|
|
436
|
+
H.map('x', maps.up, [[<Cmd>lua MiniMove.move_selection('up')<CR>]], { desc = 'Move up' })
|
|
437
|
+
|
|
438
|
+
H.map('n', maps.line_left, [[<Cmd>lua MiniMove.move_line('left')<CR>]], { desc = 'Move line left' })
|
|
439
|
+
H.map('n', maps.line_right, [[<Cmd>lua MiniMove.move_line('right')<CR>]], { desc = 'Move line right' })
|
|
440
|
+
H.map('n', maps.line_down, [[<Cmd>lua MiniMove.move_line('down')<CR>]], { desc = 'Move line down' })
|
|
441
|
+
H.map('n', maps.line_up, [[<Cmd>lua MiniMove.move_line('up')<CR>]], { desc = 'Move line up' })
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
H.is_disabled = function() return vim.g.minimove_disable == true or vim.b.minimove_disable == true end
|
|
445
|
+
|
|
446
|
+
H.get_config = function(config)
|
|
447
|
+
return vim.tbl_deep_extend('force', MiniMove.config, vim.b.minimove_config or {}, config or {})
|
|
448
|
+
end
|
|
449
|
+
|
|
450
|
+
-- Utilities ------------------------------------------------------------------
|
|
451
|
+
H.error = function(msg) error('(mini.move) ' .. msg, 0) end
|
|
452
|
+
|
|
453
|
+
H.check_type = function(name, val, ref, allow_nil)
|
|
454
|
+
if type(val) == ref or (ref == 'callable' and vim.is_callable(val)) or (allow_nil and val == nil) then return end
|
|
455
|
+
H.error(string.format('`%s` should be %s, not %s', name, ref, type(val)))
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
H.map = function(mode, lhs, rhs, opts)
|
|
459
|
+
if lhs == '' then return end
|
|
460
|
+
opts = vim.tbl_deep_extend('force', { silent = true }, opts or {})
|
|
461
|
+
vim.keymap.set(mode, lhs, rhs, opts)
|
|
462
|
+
end
|
|
463
|
+
|
|
464
|
+
H.make_cmd_normal = function(include_undojoin)
|
|
465
|
+
local normal_command = (include_undojoin and 'undojoin | ' or '') .. 'silent keepjumps normal! '
|
|
466
|
+
|
|
467
|
+
return function(x)
|
|
468
|
+
-- Caching and restoring data on every command is not necessary but leads
|
|
469
|
+
-- to a nicer implementation
|
|
470
|
+
|
|
471
|
+
-- Disable 'mini.bracketed' to avoid unwanted entries to its yank history
|
|
472
|
+
local cache_minibracketed_disable = vim.b.minibracketed_disable
|
|
473
|
+
local cache_unnamed_register = { points_to = vim.fn.getreginfo('"').points_to }
|
|
474
|
+
|
|
475
|
+
-- Don't track possible put commands into yank history
|
|
476
|
+
vim.b.minibracketed_disable = true
|
|
477
|
+
|
|
478
|
+
vim.cmd(normal_command .. x)
|
|
479
|
+
|
|
480
|
+
vim.b.minibracketed_disable = cache_minibracketed_disable
|
|
481
|
+
vim.fn.setreg('"', cache_unnamed_register)
|
|
482
|
+
end
|
|
483
|
+
end
|
|
484
|
+
|
|
485
|
+
H.get_move_state = function()
|
|
486
|
+
return {
|
|
487
|
+
buf_id = vim.api.nvim_get_current_buf(),
|
|
488
|
+
changedtick = vim.b.changedtick,
|
|
489
|
+
cursor = vim.api.nvim_win_get_cursor(0),
|
|
490
|
+
mode = vim.fn.mode(),
|
|
491
|
+
}
|
|
492
|
+
end
|
|
493
|
+
|
|
494
|
+
H.correct_cursor_col = function(ref_curpos, ref_last_col)
|
|
495
|
+
-- Use `ref_curpos = getcurpos()` instead of `vim.api.nvim_win_get_cursor(0)`
|
|
496
|
+
-- allows to also account for `virtualedit=all`
|
|
497
|
+
|
|
498
|
+
local col_diff = vim.fn.col('$') - ref_last_col
|
|
499
|
+
local new_col = math.max(ref_curpos[3] + col_diff, 1)
|
|
500
|
+
vim.fn.cursor({ vim.fn.line('.'), new_col, ref_curpos[4], ref_curpos[5] + col_diff })
|
|
501
|
+
end
|
|
502
|
+
|
|
503
|
+
H.get_curswant = function() return vim.fn.winsaveview().curswant end
|
|
504
|
+
H.set_curswant = function(x)
|
|
505
|
+
if x == nil then return end
|
|
506
|
+
vim.fn.winrestview({ curswant = x })
|
|
507
|
+
end
|
|
508
|
+
|
|
509
|
+
return MiniMove
|