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,772 @@
|
|
|
1
|
+
--- *mini.basics* Common configuration presets
|
|
2
|
+
---
|
|
3
|
+
--- MIT License Copyright (c) 2023 Evgeni Chasnovski
|
|
4
|
+
|
|
5
|
+
--- Install, create `init.lua`, add `require('mini.basics').setup()`, and you
|
|
6
|
+
--- are good to go.
|
|
7
|
+
---
|
|
8
|
+
--- Features:
|
|
9
|
+
--- - Presets for common options. It will only change option if it wasn't
|
|
10
|
+
--- manually set before. See more in |MiniBasics.config.options|.
|
|
11
|
+
---
|
|
12
|
+
--- - Presets for common mappings. It will only add a mapping if it wasn't
|
|
13
|
+
--- manually created before. See more in |MiniBasics.config.mappings|.
|
|
14
|
+
---
|
|
15
|
+
--- - Presets for common autocommands. See more in |MiniBasics.config.autocommands|.
|
|
16
|
+
---
|
|
17
|
+
--- - Reverse compatibility is a high priority. Any decision to change already
|
|
18
|
+
--- present behavior will be made with great care.
|
|
19
|
+
---
|
|
20
|
+
--- Notes:
|
|
21
|
+
--- - Main goal of this module is to provide a relatively easier way for
|
|
22
|
+
--- new-ish Neovim users to have better "works out of the box" experience
|
|
23
|
+
--- while having documented relevant options/mappings/autocommands to study.
|
|
24
|
+
--- It is based partially on survey among Neovim users and partially is
|
|
25
|
+
--- coming from personal preferences.
|
|
26
|
+
---
|
|
27
|
+
--- However, more seasoned users almost surely will find something useful.
|
|
28
|
+
---
|
|
29
|
+
--- Still, it is recommended to read about used options/mappings/autocommands
|
|
30
|
+
--- and decide if they are needed. The main way to do that is by reading
|
|
31
|
+
--- Neovim's help pages (linked in help file) and this module's source code
|
|
32
|
+
--- (thoroughly documented for easier comprehension).
|
|
33
|
+
---
|
|
34
|
+
--- # Setup ~
|
|
35
|
+
---
|
|
36
|
+
--- This module needs a setup with `require('mini.basics').setup({})` (replace
|
|
37
|
+
--- `{}` with your `config` table). It will create global Lua table `MiniBasics`
|
|
38
|
+
--- which you can use for scripting or manually (with `:lua MiniBasics.*`).
|
|
39
|
+
---
|
|
40
|
+
--- See |MiniBasics.config| for available config settings.
|
|
41
|
+
---
|
|
42
|
+
--- To stop module from showing non-error feedback, set `config.silent = true`.
|
|
43
|
+
---
|
|
44
|
+
--- # Comparisons ~
|
|
45
|
+
---
|
|
46
|
+
--- - [tpope/vim-sensible](https://github.com/tpope/vim-sensible):
|
|
47
|
+
--- - Most of `tpope/vim-sensible` is already incorporated as default
|
|
48
|
+
--- options in Neovim (see |nvim-defaults|). This module has a much
|
|
49
|
+
--- broader effect.
|
|
50
|
+
--- - [tpope/vim-unimpaired](https://github.com/tpope/vim-unimpaired):
|
|
51
|
+
--- - The `tpope/vim-unimpaired` has mapping for toggling options with `yo`
|
|
52
|
+
--- prefix. This module implements similar functionality with `\` prefix
|
|
53
|
+
--- (see |MiniBasics.config.mappings|).
|
|
54
|
+
---@tag MiniBasics
|
|
55
|
+
|
|
56
|
+
---@diagnostic disable:undefined-field
|
|
57
|
+
|
|
58
|
+
-- To study source behind presets, search for:
|
|
59
|
+
-- - `-- Options ---` for `config.options`.
|
|
60
|
+
-- - `-- Mappings ---` for `config.mappings`.
|
|
61
|
+
-- - `-- Autocommands ---` for `config.autocommands`.
|
|
62
|
+
|
|
63
|
+
-- Module definition ==========================================================
|
|
64
|
+
local MiniBasics = {}
|
|
65
|
+
local H = {}
|
|
66
|
+
|
|
67
|
+
--- Module setup
|
|
68
|
+
---
|
|
69
|
+
---@param config table|nil Module config table. See |MiniBasics.config|.
|
|
70
|
+
---
|
|
71
|
+
---@usage >lua
|
|
72
|
+
--- require('mini.basics').setup() -- use default config
|
|
73
|
+
--- -- OR
|
|
74
|
+
--- require('mini.basics').setup({}) -- replace {} with your config table
|
|
75
|
+
--- <
|
|
76
|
+
MiniBasics.setup = function(config)
|
|
77
|
+
-- TODO: Remove after Neovim=0.9 support is dropped
|
|
78
|
+
if vim.fn.has('nvim-0.10') == 0 then
|
|
79
|
+
vim.notify(
|
|
80
|
+
'(mini.basics) Neovim<0.10 is soft deprecated (module works but is not supported).'
|
|
81
|
+
.. " It will be deprecated after the next 'mini.nvim' release (module might not work)."
|
|
82
|
+
.. ' Please update your Neovim version.'
|
|
83
|
+
)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
-- Export module
|
|
87
|
+
_G.MiniBasics = MiniBasics
|
|
88
|
+
|
|
89
|
+
-- Setup config
|
|
90
|
+
config = H.setup_config(config)
|
|
91
|
+
|
|
92
|
+
-- Apply config
|
|
93
|
+
H.apply_config(config)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
--- Defaults ~
|
|
97
|
+
---@eval return MiniDoc.afterlines_to_code(MiniDoc.current.eval_section)
|
|
98
|
+
---@text # Options ~
|
|
99
|
+
--- *MiniBasics.config.options*
|
|
100
|
+
---
|
|
101
|
+
--- Usage example: >lua
|
|
102
|
+
---
|
|
103
|
+
--- require('mini.basics').setup({
|
|
104
|
+
--- options = {
|
|
105
|
+
--- basic = true,
|
|
106
|
+
--- extra_ui = true,
|
|
107
|
+
--- win_borders = 'double',
|
|
108
|
+
--- }
|
|
109
|
+
--- })
|
|
110
|
+
--- <
|
|
111
|
+
--- ## options.basic ~
|
|
112
|
+
---
|
|
113
|
+
--- The `config.options.basic` sets certain options to values which are quite
|
|
114
|
+
--- commonly used (judging by study of available Neovim pre-configurations,
|
|
115
|
+
--- public dotfiles, and surveys).
|
|
116
|
+
--- Any option is changed only if it was not set manually beforehand.
|
|
117
|
+
--- For exact changes, please see source code (`lua/mini/basics.lua`).
|
|
118
|
+
---
|
|
119
|
+
--- Here is the list of affected options (put cursor on it and press |CTRL-]|):
|
|
120
|
+
--- - General:
|
|
121
|
+
--- - Sets |<Leader>| key to |<Space>|. Be sure to make all Leader mappings
|
|
122
|
+
--- after this (otherwise they are made with default <Leader>).
|
|
123
|
+
--- - Runs `:filetype plugin indent on` (see |:filetype-overview|)
|
|
124
|
+
--- - |'backup'|
|
|
125
|
+
--- - |'mouse'|
|
|
126
|
+
--- - |'undofile'|
|
|
127
|
+
--- - |'writebackup'|
|
|
128
|
+
--- - Appearance
|
|
129
|
+
--- - |'breakindent'|
|
|
130
|
+
--- - |'cursorline'|
|
|
131
|
+
--- - |'fillchars'|
|
|
132
|
+
--- - |'linebreak'|
|
|
133
|
+
--- - |'number'|
|
|
134
|
+
--- - |'ruler'|
|
|
135
|
+
--- - |'showmode'|
|
|
136
|
+
--- - |'signcolumn'|
|
|
137
|
+
--- - |'shortmess'|
|
|
138
|
+
--- - |'splitbelow'|
|
|
139
|
+
--- - |'splitkeep'|
|
|
140
|
+
--- - |'splitright'|
|
|
141
|
+
--- - |'termguicolors'| (on Neovim<0.10; later versions have it smartly enabled)
|
|
142
|
+
--- - |'wrap'|
|
|
143
|
+
--- - Editing
|
|
144
|
+
--- - |'completeopt'|
|
|
145
|
+
--- - |'formatoptions'|
|
|
146
|
+
--- - |'ignorecase'|
|
|
147
|
+
--- - |'incsearch'|
|
|
148
|
+
--- - |'infercase'|
|
|
149
|
+
--- - |'smartcase'|
|
|
150
|
+
--- - |'smartindent'|
|
|
151
|
+
--- - |'virtualedit'|
|
|
152
|
+
---
|
|
153
|
+
--- ## options.extra_ui ~
|
|
154
|
+
---
|
|
155
|
+
--- The `config.options.extra_ui` sets certain options for visual appearance
|
|
156
|
+
--- which might not be aligned with common preferences, but still worth trying.
|
|
157
|
+
--- Any option is changed only if it was not set manually beforehand.
|
|
158
|
+
--- For exact changes, please see source code (`lua/mini/basics.lua`).
|
|
159
|
+
---
|
|
160
|
+
--- List of affected options:
|
|
161
|
+
--- - |'list'|
|
|
162
|
+
--- - |'listchars'|
|
|
163
|
+
--- - |'pumblend'|
|
|
164
|
+
--- - |'pumheight'|
|
|
165
|
+
--- - |'winblend'|
|
|
166
|
+
--- - Runs `:syntax on` (see |:syntax-on|)
|
|
167
|
+
---
|
|
168
|
+
--- ## options.win_borders ~
|
|
169
|
+
---
|
|
170
|
+
--- The `config.options.win_borders` updates |'fillchars'| to have a consistent set
|
|
171
|
+
--- of characters for window border (`vert`, `horiz`, `msgsep`, etc.).
|
|
172
|
+
---
|
|
173
|
+
--- Available values:
|
|
174
|
+
--- - `'auto'` - infer from |'winborder'|. On Neovim<0.11 do nothing.
|
|
175
|
+
--- - `'bold'` - bold lines.
|
|
176
|
+
--- - `'dot'` - dot in every cell.
|
|
177
|
+
--- - `'double'` - double line.
|
|
178
|
+
--- - `'single'` - single line.
|
|
179
|
+
--- - `'solid'` - no symbol, only background.
|
|
180
|
+
---
|
|
181
|
+
--- # Mappings ~
|
|
182
|
+
--- *MiniBasics.config.mappings*
|
|
183
|
+
---
|
|
184
|
+
--- Usage example: >lua
|
|
185
|
+
---
|
|
186
|
+
--- require('mini.basics').setup({
|
|
187
|
+
--- mappings = {
|
|
188
|
+
--- basic = true,
|
|
189
|
+
--- option_toggle_prefix = [[\]],
|
|
190
|
+
--- windows = true,
|
|
191
|
+
--- move_with_alt = true,
|
|
192
|
+
--- }
|
|
193
|
+
--- })
|
|
194
|
+
--- <
|
|
195
|
+
--- If you want some mappings to be different or not made at all, set or delete
|
|
196
|
+
--- them after calling |MiniBasics.setup()|.
|
|
197
|
+
---
|
|
198
|
+
--- ## mappings.basic ~
|
|
199
|
+
---
|
|
200
|
+
--- The `config.mappings.basic` creates mappings for certain commonly mapped actions
|
|
201
|
+
--- (judging by study of available Neovim pre-configurations and public dotfiles).
|
|
202
|
+
---
|
|
203
|
+
--- Some of the mappings override built-in ones to either improve their
|
|
204
|
+
--- behavior or override its default not very useful action.
|
|
205
|
+
--- It will only add a mapping if it wasn't manually created before.
|
|
206
|
+
---
|
|
207
|
+
--- Here is a table with created mappings : >
|
|
208
|
+
---
|
|
209
|
+
--- |Keys | Modes | Description |
|
|
210
|
+
--- |-------|-----------------|-----------------------------------------------|
|
|
211
|
+
--- | j | Normal, Visual | Move down by visible lines with no [count] |
|
|
212
|
+
--- | k | Normal, Visual | Move up by visible lines with no [count] |
|
|
213
|
+
--- | go | Normal | Add [count] empty lines after cursor |
|
|
214
|
+
--- | gO | Normal | Add [count] empty lines before cursor |
|
|
215
|
+
--- | gy | Normal, Visual | Copy to system clipboard |
|
|
216
|
+
--- | gp | Normal, Visual | Paste from system clipboard |
|
|
217
|
+
--- | gV | Normal | Visually select latest changed or yanked text |
|
|
218
|
+
--- | g/ | Visual | Search inside current visual selection |
|
|
219
|
+
--- | * | Visual | Search forward for current visual selection |
|
|
220
|
+
--- | # | Visual | Search backward for current visual selection |
|
|
221
|
+
--- | <C-s> | Normal, Visual, | Save and go to Normal mode |
|
|
222
|
+
--- | | Insert | |
|
|
223
|
+
--- <
|
|
224
|
+
--- Notes:
|
|
225
|
+
--- - See |[count]| for its meaning.
|
|
226
|
+
--- - On Neovim>=0.10 mappings for `#` and `*` are not created as their
|
|
227
|
+
--- enhanced variants are made built-in. See |v_star-default| and |v_#-default|.
|
|
228
|
+
--- - On Neovim>=0.11 there are |[<Space>| / |]<Space>| for adding empty lines.
|
|
229
|
+
--- The `gO` and `go` mappings are still created as they are more aligned with
|
|
230
|
+
--- similarly purposed |O| and |o| keys (although sometimes conflict with |gO|).
|
|
231
|
+
---
|
|
232
|
+
--- ## mappings.option_toggle_prefix ~
|
|
233
|
+
---
|
|
234
|
+
--- The `config.mappings.option_toggle_prefix` defines a prefix used for
|
|
235
|
+
--- creating mappings that toggle common options. The result mappings will be
|
|
236
|
+
--- `<prefix> + <suffix>`. For example, with default value, `\w` will toggle |'wrap'|.
|
|
237
|
+
---
|
|
238
|
+
--- Other viable choices for prefix are
|
|
239
|
+
--- - `,` (as a mnemonic for several values to toggle).
|
|
240
|
+
--- - `|` (as a same mnemonic).
|
|
241
|
+
--- - `yo` (used in `tpope/vim-unimpaired`)
|
|
242
|
+
--- - Something with |<Leader>| key, like `<Leader>t` (`t` for "toggle"). Note:
|
|
243
|
+
--- if your prefix contains `<Leader>` key, make sure to set it before
|
|
244
|
+
--- calling |MiniBasics.setup()| (as is done with default `basic` field of
|
|
245
|
+
--- |MiniBasics.config.options|).
|
|
246
|
+
---
|
|
247
|
+
--- After toggling, there will be a feedback about the current option value if
|
|
248
|
+
--- prior to `require('mini.basics').setup()` module wasn't silenced (see
|
|
249
|
+
--- "Silencing" section in |mini.basics|).
|
|
250
|
+
---
|
|
251
|
+
--- It will only add a mapping if it wasn't manually created before.
|
|
252
|
+
---
|
|
253
|
+
--- Here is a list of suffixes for created toggling mappings (all in Normal mode):
|
|
254
|
+
---
|
|
255
|
+
--- - `b` - |'background'|.
|
|
256
|
+
--- - `c` - |'cursorline'|.
|
|
257
|
+
--- - `C` - |'cursorcolumn'|.
|
|
258
|
+
--- - `d` - diagnostic (via |vim.diagnostic| functions).
|
|
259
|
+
--- - `h` - |'hlsearch'| (or |v:hlsearch| to be precise).
|
|
260
|
+
--- - `i` - |'ignorecase'|.
|
|
261
|
+
--- - `l` - |'list'|.
|
|
262
|
+
--- - `n` - |'number'|.
|
|
263
|
+
--- - `r` - |'relativenumber'|.
|
|
264
|
+
--- - `s` - |'spell'|.
|
|
265
|
+
--- - `w` - |'wrap'|.
|
|
266
|
+
---
|
|
267
|
+
--- ## mappings.windows ~
|
|
268
|
+
---
|
|
269
|
+
--- The `config.mappings.windows` creates mappings for easiere window manipulation.
|
|
270
|
+
---
|
|
271
|
+
--- It will only add a mapping if it wasn't manually created before.
|
|
272
|
+
---
|
|
273
|
+
--- Here is a list with created Normal mode mappings (all respect |[count]|):
|
|
274
|
+
--- - Window navigation:
|
|
275
|
+
--- - `<C-h>` - focus on left window (see |CTRL-W_H|).
|
|
276
|
+
--- - `<C-j>` - focus on below window (see |CTRL-W_J|).
|
|
277
|
+
--- - `<C-k>` - focus on above window (see |CTRL-W_K|).
|
|
278
|
+
--- - `<C-l>` - focus on right window (see |CTRL-W_L|).
|
|
279
|
+
--- - Window resize (all use arrow keys; variants of |:resize|; respect |[count]|):
|
|
280
|
+
--- - `<C-left>` - decrease window width.
|
|
281
|
+
--- - `<C-down>` - decrease window height.
|
|
282
|
+
--- - `<C-up>` - increase window height.
|
|
283
|
+
--- - `<C-right>` - increase window width.
|
|
284
|
+
---
|
|
285
|
+
--- ## mappings.move_with_alt ~
|
|
286
|
+
---
|
|
287
|
+
--- The `config.mappings.move_with_alt` creates mappings for a more consistent
|
|
288
|
+
--- cursor move in Insert, Command, and Terminal modes. For example, it proves
|
|
289
|
+
--- useful in combination of autopair plugin (like |mini.pairs|) to move right
|
|
290
|
+
--- outside of inserted pairs (no matter what the pair is).
|
|
291
|
+
---
|
|
292
|
+
--- It will only add a mapping if it wasn't manually created before.
|
|
293
|
+
---
|
|
294
|
+
--- Here is a list of created mappings (`<M-x>` means `Alt`/`Meta` plus `x`):
|
|
295
|
+
--- - `<M-h>` - move cursor left. Modes: Insert, Terminal, Command.
|
|
296
|
+
--- - `<M-j>` - move cursor down. Modes: Insert, Terminal.
|
|
297
|
+
--- - `<M-k>` - move cursor up. Modes: Insert, Terminal.
|
|
298
|
+
--- - `<M-l>` - move cursor right. Modes: Insert, Terminal, Command.
|
|
299
|
+
---
|
|
300
|
+
--- # Autocommands ~
|
|
301
|
+
--- *MiniBasics.config.autocommands*
|
|
302
|
+
---
|
|
303
|
+
--- Usage example: >lua
|
|
304
|
+
---
|
|
305
|
+
--- require('mini.basics').setup({
|
|
306
|
+
--- autocommands = {
|
|
307
|
+
--- basic = true,
|
|
308
|
+
--- relnum_in_visual_mode = true,
|
|
309
|
+
--- }
|
|
310
|
+
--- })
|
|
311
|
+
--- <
|
|
312
|
+
--- ## autocommands.basic ~
|
|
313
|
+
---
|
|
314
|
+
--- The `config.autocommands.basic` creates some common autocommands:
|
|
315
|
+
---
|
|
316
|
+
--- - Starts insert mode when opening terminal (see |:startinsert| and |TermOpen|).
|
|
317
|
+
--- - Highlights yanked text for a brief period of time. See |vim.hl.on_yank()|
|
|
318
|
+
--- (which is |vim.hl.hl_op()| on Neovim>=0.13 and |vim.highlight.on_yank()|
|
|
319
|
+
--- on Neovim<0.11) and |TextYankPost|.
|
|
320
|
+
---
|
|
321
|
+
--- ## autocommands.relnum_in_visual_mode ~
|
|
322
|
+
---
|
|
323
|
+
--- The `config.autocommands.relnum_in_visual_mode` creates autocommands that
|
|
324
|
+
--- enable |'relativenumber'| in linewise and blockwise Visual modes and disable
|
|
325
|
+
--- otherwise. See |ModeChanged|.
|
|
326
|
+
MiniBasics.config = {
|
|
327
|
+
-- Options. Set field to `false` to disable.
|
|
328
|
+
options = {
|
|
329
|
+
-- Basic options ('number', 'ignorecase', and many more)
|
|
330
|
+
basic = true,
|
|
331
|
+
|
|
332
|
+
-- Extra UI features ('winblend', 'listchars', 'pumheight', ...)
|
|
333
|
+
extra_ui = false,
|
|
334
|
+
|
|
335
|
+
-- Presets for window borders ('single', 'double', ...)
|
|
336
|
+
-- Default 'auto' infers from 'winborder' option
|
|
337
|
+
win_borders = 'auto',
|
|
338
|
+
},
|
|
339
|
+
|
|
340
|
+
-- Mappings. Set field to `false` to disable.
|
|
341
|
+
mappings = {
|
|
342
|
+
-- Basic mappings (better 'jk', save with Ctrl+S, ...)
|
|
343
|
+
basic = true,
|
|
344
|
+
|
|
345
|
+
-- Prefix for mappings that toggle common options ('wrap', 'spell', ...).
|
|
346
|
+
-- Supply empty string to not create these mappings.
|
|
347
|
+
option_toggle_prefix = [[\]],
|
|
348
|
+
|
|
349
|
+
-- Window navigation with <C-hjkl>, resize with <C-arrow>
|
|
350
|
+
windows = false,
|
|
351
|
+
|
|
352
|
+
-- Move cursor in Insert, Command, and Terminal mode with <M-hjkl>
|
|
353
|
+
move_with_alt = false,
|
|
354
|
+
},
|
|
355
|
+
|
|
356
|
+
-- Autocommands. Set field to `false` to disable
|
|
357
|
+
autocommands = {
|
|
358
|
+
-- Basic autocommands (highlight on yank, start Insert in terminal, ...)
|
|
359
|
+
basic = true,
|
|
360
|
+
|
|
361
|
+
-- Set 'relativenumber' only in linewise and blockwise Visual mode
|
|
362
|
+
relnum_in_visual_mode = false,
|
|
363
|
+
},
|
|
364
|
+
|
|
365
|
+
-- Whether to disable showing non-error feedback
|
|
366
|
+
silent = false,
|
|
367
|
+
}
|
|
368
|
+
--minidoc_afterlines_end
|
|
369
|
+
|
|
370
|
+
--- Toggle diagnostic for current buffer
|
|
371
|
+
---
|
|
372
|
+
--- This uses |vim.diagnostic| functions per buffer.
|
|
373
|
+
---
|
|
374
|
+
---@return string String indicator for new state. Similar to what |:set| `{option}?` shows.
|
|
375
|
+
MiniBasics.toggle_diagnostic = function()
|
|
376
|
+
local buf_id = vim.api.nvim_get_current_buf()
|
|
377
|
+
local is_enabled = H.diagnostic_is_enabled(buf_id)
|
|
378
|
+
|
|
379
|
+
local f
|
|
380
|
+
if vim.fn.has('nvim-0.10') == 1 then
|
|
381
|
+
f = function(bufnr) vim.diagnostic.enable(not is_enabled, { bufnr = bufnr }) end
|
|
382
|
+
else
|
|
383
|
+
f = is_enabled and vim.diagnostic.disable or vim.diagnostic.enable
|
|
384
|
+
end
|
|
385
|
+
f(buf_id)
|
|
386
|
+
|
|
387
|
+
local new_buf_state = not is_enabled
|
|
388
|
+
|
|
389
|
+
return new_buf_state and ' diagnostic' or 'nodiagnostic'
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
-- Helper data ================================================================
|
|
393
|
+
-- Module default config
|
|
394
|
+
H.default_config = vim.deepcopy(MiniBasics.config)
|
|
395
|
+
|
|
396
|
+
-- Helper functionality =======================================================
|
|
397
|
+
-- Settings -------------------------------------------------------------------
|
|
398
|
+
H.setup_config = function(config)
|
|
399
|
+
H.check_type('config', config, 'table', true)
|
|
400
|
+
config = vim.tbl_deep_extend('force', vim.deepcopy(H.default_config), config or {})
|
|
401
|
+
|
|
402
|
+
H.check_type('options', config.options, 'table')
|
|
403
|
+
|
|
404
|
+
H.check_type('options.basic', config.options.basic, 'boolean')
|
|
405
|
+
H.check_type('options.extra_ui', config.options.extra_ui, 'boolean')
|
|
406
|
+
H.check_type('options.win_borders', config.options.win_borders, 'string')
|
|
407
|
+
|
|
408
|
+
H.check_type('mappings', config.mappings, 'table')
|
|
409
|
+
H.check_type('mappings.basic', config.mappings.basic, 'boolean')
|
|
410
|
+
H.check_type('mappings.option_toggle_prefix', config.mappings.option_toggle_prefix, 'string')
|
|
411
|
+
H.check_type('mappings.windows', config.mappings.windows, 'boolean')
|
|
412
|
+
H.check_type('mappings.move_with_alt', config.mappings.move_with_alt, 'boolean')
|
|
413
|
+
|
|
414
|
+
H.check_type('autocommands', config.autocommands, 'table')
|
|
415
|
+
H.check_type('autocommands.basic', config.autocommands.basic, 'boolean')
|
|
416
|
+
H.check_type('autocommands.relnum_in_visual_mode', config.autocommands.relnum_in_visual_mode, 'boolean')
|
|
417
|
+
|
|
418
|
+
H.check_type('silent', config.silent, 'boolean')
|
|
419
|
+
|
|
420
|
+
return config
|
|
421
|
+
end
|
|
422
|
+
|
|
423
|
+
H.apply_config = function(config)
|
|
424
|
+
MiniBasics.config = config
|
|
425
|
+
|
|
426
|
+
H.apply_options(config)
|
|
427
|
+
H.apply_mappings(config)
|
|
428
|
+
H.apply_autocommands(config)
|
|
429
|
+
end
|
|
430
|
+
|
|
431
|
+
-- Options --------------------------------------------------------------------
|
|
432
|
+
--stylua: ignore
|
|
433
|
+
H.apply_options = function(config)
|
|
434
|
+
-- Use `local o, opt = vim.o, vim.opt` to copy lines as is.
|
|
435
|
+
-- Or use `vim.o` and `vim.opt` directly.
|
|
436
|
+
local o, opt = H.vim_o, H.vim_opt
|
|
437
|
+
|
|
438
|
+
-- Basic options
|
|
439
|
+
if config.options.basic then
|
|
440
|
+
-- Leader key
|
|
441
|
+
if vim.g.mapleader == nil then
|
|
442
|
+
vim.g.mapleader = ' ' -- Use space as the one and only true Leader key
|
|
443
|
+
end
|
|
444
|
+
|
|
445
|
+
-- General
|
|
446
|
+
o.undofile = true -- Enable persistent undo (see also `:h undodir`)
|
|
447
|
+
|
|
448
|
+
o.backup = false -- Don't store backup while overwriting the file
|
|
449
|
+
o.writebackup = false -- Don't store backup while overwriting the file
|
|
450
|
+
|
|
451
|
+
o.mouse = 'a' -- Enable mouse for all available modes
|
|
452
|
+
|
|
453
|
+
vim.cmd('filetype plugin indent on') -- Enable all filetype plugins
|
|
454
|
+
|
|
455
|
+
-- Appearance
|
|
456
|
+
o.breakindent = true -- Indent wrapped lines to match line start
|
|
457
|
+
o.cursorline = true -- Highlight current line
|
|
458
|
+
o.linebreak = true -- Wrap long lines at 'breakat' (if 'wrap' is set)
|
|
459
|
+
o.number = true -- Show line numbers
|
|
460
|
+
o.splitbelow = true -- Horizontal splits will be below
|
|
461
|
+
o.splitright = true -- Vertical splits will be to the right
|
|
462
|
+
|
|
463
|
+
o.ruler = false -- Don't show cursor position in command line
|
|
464
|
+
o.showmode = false -- Don't show mode in command line
|
|
465
|
+
o.wrap = false -- Display long lines as just one line
|
|
466
|
+
|
|
467
|
+
o.signcolumn = 'yes' -- Always show sign column (otherwise it will shift text)
|
|
468
|
+
o.fillchars = 'eob: ' -- Don't show `~` outside of buffer
|
|
469
|
+
|
|
470
|
+
-- Editing
|
|
471
|
+
o.ignorecase = true -- Ignore case when searching (use `\C` to force not doing that)
|
|
472
|
+
o.incsearch = true -- Show search results while typing
|
|
473
|
+
o.infercase = true -- Infer letter cases for a richer built-in keyword completion
|
|
474
|
+
o.smartcase = true -- Don't ignore case when searching if pattern has upper case
|
|
475
|
+
o.smartindent = true -- Make indenting smart
|
|
476
|
+
|
|
477
|
+
o.completeopt = 'menuone,noselect' -- Customize completions
|
|
478
|
+
o.virtualedit = 'block' -- Allow going past the end of line in visual block mode
|
|
479
|
+
o.formatoptions = 'qjl1' -- Don't autoformat comments
|
|
480
|
+
|
|
481
|
+
-- Neovim version dependent
|
|
482
|
+
opt.shortmess:append('WcC') -- Reduce command line messages
|
|
483
|
+
o.splitkeep = 'screen' -- Reduce scroll during window split
|
|
484
|
+
|
|
485
|
+
if vim.fn.has('nvim-0.10') == 0 then
|
|
486
|
+
o.termguicolors = true -- Enable gui colors
|
|
487
|
+
end
|
|
488
|
+
end
|
|
489
|
+
|
|
490
|
+
-- Some opinioneted extra UI options
|
|
491
|
+
if config.options.extra_ui then
|
|
492
|
+
o.pumblend = 10 -- Make builtin completion menus slightly transparent
|
|
493
|
+
o.pumheight = 10 -- Make popup menu smaller
|
|
494
|
+
o.winblend = 10 -- Make floating windows slightly transparent
|
|
495
|
+
|
|
496
|
+
-- NOTE: Having `tab` present is needed because `^I` will be shown if
|
|
497
|
+
-- omitted (documented in `:h listchars`).
|
|
498
|
+
-- Having it equal to a default value should be less intrusive.
|
|
499
|
+
o.listchars = 'tab:> ,extends:…,precedes:…,nbsp:␣' -- Define which helper symbols to show
|
|
500
|
+
o.list = true -- Show some helper symbols
|
|
501
|
+
|
|
502
|
+
-- Enable syntax highlighting if it wasn't already (as it is time consuming)
|
|
503
|
+
if vim.fn.exists("syntax_on") ~= 1 then vim.cmd([[syntax enable]]) end
|
|
504
|
+
end
|
|
505
|
+
|
|
506
|
+
-- Use some common window borders presets
|
|
507
|
+
local win_borders = config.options.win_borders
|
|
508
|
+
if win_borders == 'auto' and vim.fn.has('nvim-0.11') == 1 then
|
|
509
|
+
local option_value = vim.o.winborder
|
|
510
|
+
win_borders = H.winborder_map[option_value] or option_value
|
|
511
|
+
end
|
|
512
|
+
local border_chars = H.win_borders_fillchars[win_borders]
|
|
513
|
+
if border_chars ~= nil then vim.opt.fillchars:append(border_chars) end
|
|
514
|
+
end
|
|
515
|
+
|
|
516
|
+
H.vim_o = setmetatable({}, {
|
|
517
|
+
__newindex = function(_, name, value)
|
|
518
|
+
local was_set = vim.api.nvim_get_option_info2(name, { scope = 'global' }).was_set
|
|
519
|
+
if was_set then return end
|
|
520
|
+
|
|
521
|
+
vim.o[name] = value
|
|
522
|
+
end,
|
|
523
|
+
})
|
|
524
|
+
|
|
525
|
+
H.vim_opt = setmetatable({}, {
|
|
526
|
+
__index = function(_, name)
|
|
527
|
+
local was_set = vim.api.nvim_get_option_info2(name, { scope = 'global' }).was_set
|
|
528
|
+
if was_set then return { append = function() end, remove = function() end } end
|
|
529
|
+
|
|
530
|
+
return vim.opt[name]
|
|
531
|
+
end,
|
|
532
|
+
})
|
|
533
|
+
|
|
534
|
+
--stylua: ignore
|
|
535
|
+
H.win_borders_fillchars = {
|
|
536
|
+
bold = 'vert:┃,horiz:━,horizdown:┳,horizup:┻,verthoriz:╋,vertleft:┫,vertright:┣,msgsep:━',
|
|
537
|
+
dot = 'vert:·,horiz:·,horizdown:·,horizup:·,verthoriz:·,vertleft:·,vertright:·,msgsep:·',
|
|
538
|
+
double = 'vert:║,horiz:═,horizdown:╦,horizup:╩,verthoriz:╬,vertleft:╣,vertright:╠,msgsep:═',
|
|
539
|
+
single = 'vert:│,horiz:─,horizdown:┬,horizup:┴,verthoriz:┼,vertleft:┤,vertright:├,msgsep:─',
|
|
540
|
+
solid = 'vert: ,horiz: ,horizdown: ,horizup: ,verthoriz: ,vertleft: ,vertright: ,msgsep: ',
|
|
541
|
+
}
|
|
542
|
+
H.winborder_map = { none = 'solid', rounded = 'single', shadow = 'solid' }
|
|
543
|
+
|
|
544
|
+
-- Mappings -------------------------------------------------------------------
|
|
545
|
+
--stylua: ignore
|
|
546
|
+
H.apply_mappings = function(config)
|
|
547
|
+
-- Use `local map = vim.keymap.set` to copy lines as is. Or use it directly.
|
|
548
|
+
local map = H.keymap_set
|
|
549
|
+
|
|
550
|
+
if config.mappings.basic then
|
|
551
|
+
-- Move by visible lines. Notes:
|
|
552
|
+
-- - Don't map in Operator-pending mode because it severely changes behavior:
|
|
553
|
+
-- like `dj` on non-wrapped line will not delete it.
|
|
554
|
+
-- - Condition on `v:count == 0` to allow easier use of relative line numbers.
|
|
555
|
+
map({ 'n', 'x' }, 'j', [[v:count == 0 ? 'gj' : 'j']], { expr = true })
|
|
556
|
+
map({ 'n', 'x' }, 'k', [[v:count == 0 ? 'gk' : 'k']], { expr = true })
|
|
557
|
+
|
|
558
|
+
-- Add empty lines before and after cursor line supporting dot-repeat
|
|
559
|
+
MiniBasics.put_empty_line = function(put_above)
|
|
560
|
+
-- This has a typical workflow for enabling dot-repeat:
|
|
561
|
+
-- - On first call it sets `operatorfunc`, caches data, and calls
|
|
562
|
+
-- `operatorfunc` on current cursor position.
|
|
563
|
+
-- - On second call it performs task: puts `v:count1` empty lines
|
|
564
|
+
-- above/below current line.
|
|
565
|
+
if type(put_above) == 'boolean' then
|
|
566
|
+
vim.o.operatorfunc = 'v:lua.MiniBasics.put_empty_line'
|
|
567
|
+
MiniBasics.cache_empty_line = { put_above = put_above }
|
|
568
|
+
return 'g@l'
|
|
569
|
+
end
|
|
570
|
+
|
|
571
|
+
local target_line = vim.fn.line('.') - (MiniBasics.cache_empty_line.put_above and 1 or 0)
|
|
572
|
+
vim.fn.append(target_line, vim.fn['repeat']({ '' }, vim.v.count1))
|
|
573
|
+
end
|
|
574
|
+
|
|
575
|
+
-- NOTE: if you don't want to support dot-repeat, use this snippet:
|
|
576
|
+
-- ```
|
|
577
|
+
-- map('n', 'gO', "<Cmd>call append(line('.') - 1, repeat([''], v:count1))<CR>")
|
|
578
|
+
-- map('n', 'go', "<Cmd>call append(line('.'), repeat([''], v:count1))<CR>")
|
|
579
|
+
-- ```
|
|
580
|
+
map('n', 'gO', 'v:lua.MiniBasics.put_empty_line(v:true)', { expr = true, desc = 'Put empty line above' })
|
|
581
|
+
map('n', 'go', 'v:lua.MiniBasics.put_empty_line(v:false)', { expr = true, desc = 'Put empty line below' })
|
|
582
|
+
|
|
583
|
+
-- Copy/paste with system clipboard
|
|
584
|
+
map({ 'n', 'x' }, 'gy', '"+y', { desc = 'Copy to system clipboard' })
|
|
585
|
+
map( 'n', 'gp', '"+p', { desc = 'Paste from system clipboard' })
|
|
586
|
+
-- - Paste in Visual with `P` to not copy selected text (`:h v_P`)
|
|
587
|
+
map( 'x', 'gp', '"+P', { desc = 'Paste from system clipboard' })
|
|
588
|
+
|
|
589
|
+
-- Reselect latest changed, put, or yanked text
|
|
590
|
+
map('n', 'gV', '"g`[" . strpart(getregtype(), 0, 1) . "g`]"', { expr = true, replace_keycodes = false, desc = 'Visually select changed text' })
|
|
591
|
+
|
|
592
|
+
-- Search inside visually highlighted text. Use `silent = false` for it to
|
|
593
|
+
-- make effect immediately.
|
|
594
|
+
map('x', 'g/', '<esc>/\\%V', { silent = false, desc = 'Search inside visual selection' })
|
|
595
|
+
|
|
596
|
+
-- Search visually selected text (slightly better than builtins in
|
|
597
|
+
-- Neovim<0.10 but slightly worse than builtins in Neovim>=0.10)
|
|
598
|
+
-- TODO: Remove this after compatibility with Neovim=0.9 is dropped
|
|
599
|
+
if vim.fn.has('nvim-0.10') == 0 then
|
|
600
|
+
map('x', '*', [[y/\V<C-R>=escape(@", '/\')<CR><CR>]], { desc = 'Search forward' })
|
|
601
|
+
map('x', '#', [[y?\V<C-R>=escape(@", '?\')<CR><CR>]], { desc = 'Search backward' })
|
|
602
|
+
end
|
|
603
|
+
|
|
604
|
+
-- Alternative way to save and exit in Normal mode.
|
|
605
|
+
-- NOTE: Adding `redraw` helps with `cmdheight=0` if buffer is not modified
|
|
606
|
+
map( 'n', '<C-S>', '<Cmd>silent! update | redraw<CR>', { desc = 'Save' })
|
|
607
|
+
map({ 'i', 'x' }, '<C-S>', '<Esc><Cmd>silent! update | redraw<CR>', { desc = 'Save and go to Normal mode' })
|
|
608
|
+
end
|
|
609
|
+
|
|
610
|
+
local toggle_prefix = config.mappings.option_toggle_prefix
|
|
611
|
+
if type(toggle_prefix) == 'string' and toggle_prefix ~= '' then
|
|
612
|
+
local map_toggle = function(lhs, rhs, desc) map('n', toggle_prefix .. lhs, rhs, { desc = desc }) end
|
|
613
|
+
|
|
614
|
+
if config.silent then
|
|
615
|
+
-- Toggle without feedback
|
|
616
|
+
map_toggle('b', '<Cmd>lua vim.o.bg = vim.o.bg == "dark" and "light" or "dark"<CR>', "Toggle 'background'")
|
|
617
|
+
map_toggle('c', '<Cmd>setlocal cursorline!<CR>', "Toggle 'cursorline'")
|
|
618
|
+
map_toggle('C', '<Cmd>setlocal cursorcolumn!<CR>', "Toggle 'cursorcolumn'")
|
|
619
|
+
map_toggle('d', '<Cmd>lua MiniBasics.toggle_diagnostic()<CR>', 'Toggle diagnostic')
|
|
620
|
+
map_toggle('h', '<Cmd>let v:hlsearch = 1 - v:hlsearch<CR>', 'Toggle search highlight')
|
|
621
|
+
map_toggle('i', '<Cmd>setlocal ignorecase!<CR>', "Toggle 'ignorecase'")
|
|
622
|
+
map_toggle('l', '<Cmd>setlocal list!<CR>', "Toggle 'list'")
|
|
623
|
+
map_toggle('n', '<Cmd>setlocal number!<CR>', "Toggle 'number'")
|
|
624
|
+
map_toggle('r', '<Cmd>setlocal relativenumber!<CR>', "Toggle 'relativenumber'")
|
|
625
|
+
map_toggle('s', '<Cmd>setlocal spell!<CR>', "Toggle 'spell'")
|
|
626
|
+
map_toggle('w', '<Cmd>setlocal wrap!<CR>', "Toggle 'wrap'")
|
|
627
|
+
else
|
|
628
|
+
map_toggle('b', '<Cmd>lua vim.o.bg = vim.o.bg == "dark" and "light" or "dark"; print(vim.o.bg)<CR>', "Toggle 'background'")
|
|
629
|
+
map_toggle('c', '<Cmd>setlocal cursorline! cursorline?<CR>', "Toggle 'cursorline'")
|
|
630
|
+
map_toggle('C', '<Cmd>setlocal cursorcolumn! cursorcolumn?<CR>', "Toggle 'cursorcolumn'")
|
|
631
|
+
map_toggle('d', '<Cmd>lua print(MiniBasics.toggle_diagnostic())<CR>', 'Toggle diagnostic')
|
|
632
|
+
map_toggle('h', '<Cmd>let v:hlsearch = 1 - v:hlsearch | echo (v:hlsearch ? " " : "no") . "hlsearch"<CR>', 'Toggle search highlight')
|
|
633
|
+
map_toggle('i', '<Cmd>setlocal ignorecase! ignorecase?<CR>', "Toggle 'ignorecase'")
|
|
634
|
+
map_toggle('l', '<Cmd>setlocal list! list?<CR>', "Toggle 'list'")
|
|
635
|
+
map_toggle('n', '<Cmd>setlocal number! number?<CR>', "Toggle 'number'")
|
|
636
|
+
map_toggle('r', '<Cmd>setlocal relativenumber! relativenumber?<CR>', "Toggle 'relativenumber'")
|
|
637
|
+
map_toggle('s', '<Cmd>setlocal spell! spell?<CR>', "Toggle 'spell'")
|
|
638
|
+
map_toggle('w', '<Cmd>setlocal wrap! wrap?<CR>', "Toggle 'wrap'")
|
|
639
|
+
end
|
|
640
|
+
end
|
|
641
|
+
|
|
642
|
+
if config.mappings.windows then
|
|
643
|
+
-- Window navigation
|
|
644
|
+
map('n', '<C-H>', '<C-w>h', { desc = 'Focus on left window' })
|
|
645
|
+
map('n', '<C-J>', '<C-w>j', { desc = 'Focus on below window' })
|
|
646
|
+
map('n', '<C-K>', '<C-w>k', { desc = 'Focus on above window' })
|
|
647
|
+
map('n', '<C-L>', '<C-w>l', { desc = 'Focus on right window' })
|
|
648
|
+
|
|
649
|
+
-- Window resize (respecting `v:count`)
|
|
650
|
+
map('n', '<C-Left>', '"<Cmd>vertical resize -" . v:count1 . "<CR>"', { expr = true, replace_keycodes = false, desc = 'Decrease window width' })
|
|
651
|
+
map('n', '<C-Down>', '"<Cmd>resize -" . v:count1 . "<CR>"', { expr = true, replace_keycodes = false, desc = 'Decrease window height' })
|
|
652
|
+
map('n', '<C-Up>', '"<Cmd>resize +" . v:count1 . "<CR>"', { expr = true, replace_keycodes = false, desc = 'Increase window height' })
|
|
653
|
+
map('n', '<C-Right>', '"<Cmd>vertical resize +" . v:count1 . "<CR>"', { expr = true, replace_keycodes = false, desc = 'Increase window width' })
|
|
654
|
+
end
|
|
655
|
+
|
|
656
|
+
if config.mappings.move_with_alt then
|
|
657
|
+
-- Move only sideways in command mode. Using `silent = false` makes movements
|
|
658
|
+
-- to be immediately shown.
|
|
659
|
+
map('c', '<M-h>', '<Left>', { silent = false, desc = 'Left' })
|
|
660
|
+
map('c', '<M-l>', '<Right>', { silent = false, desc = 'Right' })
|
|
661
|
+
|
|
662
|
+
-- Don't `noremap` in insert mode to have these keybindings behave exactly
|
|
663
|
+
-- like arrows (crucial inside TelescopePrompt)
|
|
664
|
+
map('i', '<M-h>', '<Left>', { noremap = false, desc = 'Left' })
|
|
665
|
+
map('i', '<M-j>', '<Down>', { noremap = false, desc = 'Down' })
|
|
666
|
+
map('i', '<M-k>', '<Up>', { noremap = false, desc = 'Up' })
|
|
667
|
+
map('i', '<M-l>', '<Right>', { noremap = false, desc = 'Right' })
|
|
668
|
+
|
|
669
|
+
map('t', '<M-h>', '<Left>', { desc = 'Left' })
|
|
670
|
+
map('t', '<M-j>', '<Down>', { desc = 'Down' })
|
|
671
|
+
map('t', '<M-k>', '<Up>', { desc = 'Up' })
|
|
672
|
+
map('t', '<M-l>', '<Right>', { desc = 'Right' })
|
|
673
|
+
end
|
|
674
|
+
end
|
|
675
|
+
|
|
676
|
+
H.keymap_set = function(modes, lhs, rhs, opts)
|
|
677
|
+
-- NOTE: Use `<C-H>`, `<C-Up>`, `<M-h>` casing (instead of `<C-h>`, `<C-up>`,
|
|
678
|
+
-- `<M-H>`) to match the `lhs` of keymap info. Otherwise it will say that
|
|
679
|
+
-- mapping doesn't exist when in fact it does.
|
|
680
|
+
if type(modes) == 'string' then modes = { modes } end
|
|
681
|
+
|
|
682
|
+
for _, mode in ipairs(modes) do
|
|
683
|
+
-- Don't map if mapping is already set **globally**
|
|
684
|
+
local map_info = H.get_map_info(mode, lhs)
|
|
685
|
+
if not H.is_default_keymap(mode, lhs, map_info) then return end
|
|
686
|
+
|
|
687
|
+
-- Map
|
|
688
|
+
H.map(mode, lhs, rhs, opts)
|
|
689
|
+
end
|
|
690
|
+
end
|
|
691
|
+
|
|
692
|
+
H.is_default_keymap = function(mode, lhs, map_info)
|
|
693
|
+
if map_info == nil then return true end
|
|
694
|
+
local rhs, desc = map_info.rhs or '', map_info.desc or ''
|
|
695
|
+
|
|
696
|
+
-- Some mappings are set by default in Neovim
|
|
697
|
+
if mode == 'n' and lhs == '<C-L>' then return rhs:find('nohl') ~= nil end
|
|
698
|
+
if mode == 'n' and lhs == 'gO' and vim.fn.has('nvim-0.11') == 1 then return desc:find('vim%.lsp') ~= nil end
|
|
699
|
+
if mode == 'i' and lhs == '<C-S>' then return desc:find('signature') ~= nil end
|
|
700
|
+
if mode == 'x' and lhs == '*' then return rhs == [[y/\V<C-R>"<CR>]] end
|
|
701
|
+
if mode == 'x' and lhs == '#' then return rhs == [[y?\V<C-R>"<CR>]] end
|
|
702
|
+
end
|
|
703
|
+
|
|
704
|
+
H.get_map_info = function(mode, lhs)
|
|
705
|
+
local keymaps = vim.api.nvim_get_keymap(mode)
|
|
706
|
+
for _, info in ipairs(keymaps) do
|
|
707
|
+
if info.lhs == lhs then return info end
|
|
708
|
+
end
|
|
709
|
+
end
|
|
710
|
+
|
|
711
|
+
-- Autocommands ---------------------------------------------------------------
|
|
712
|
+
H.apply_autocommands = function(config)
|
|
713
|
+
local gr = vim.api.nvim_create_augroup('MiniBasicsAutocommands', {})
|
|
714
|
+
|
|
715
|
+
local au = function(event, pattern, callback, desc)
|
|
716
|
+
vim.api.nvim_create_autocmd(event, { group = gr, pattern = pattern, callback = callback, desc = desc })
|
|
717
|
+
end
|
|
718
|
+
|
|
719
|
+
if config.autocommands.basic then
|
|
720
|
+
local f = function() vim.hl.hl_op() end
|
|
721
|
+
if vim.fn.has('nvim-0.13') == 0 then f = function() vim.hl.on_yank() end end
|
|
722
|
+
if vim.fn.has('nvim-0.11') == 0 then f = function() vim.highlight.on_yank() end end
|
|
723
|
+
au('TextYankPost', '*', f, 'Highlight yanked text')
|
|
724
|
+
|
|
725
|
+
local start_terminal_insert = vim.schedule_wrap(function(data)
|
|
726
|
+
-- Try to start terminal mode only if target terminal is current
|
|
727
|
+
if not (vim.api.nvim_get_current_buf() == data.buf and vim.bo.buftype == 'terminal') then return end
|
|
728
|
+
vim.cmd('startinsert')
|
|
729
|
+
end)
|
|
730
|
+
au('TermOpen', 'term://*', start_terminal_insert, 'Start builtin terminal in Insert mode')
|
|
731
|
+
end
|
|
732
|
+
|
|
733
|
+
if config.autocommands.relnum_in_visual_mode then
|
|
734
|
+
au(
|
|
735
|
+
'ModeChanged',
|
|
736
|
+
-- Show relative numbers only when they matter (linewise and blockwise
|
|
737
|
+
-- selection) and 'number' is set (avoids horizontal flickering)
|
|
738
|
+
'*:[V\x16]*',
|
|
739
|
+
function() vim.wo.relativenumber = vim.wo.number end,
|
|
740
|
+
'Show relative line numbers'
|
|
741
|
+
)
|
|
742
|
+
au(
|
|
743
|
+
'ModeChanged',
|
|
744
|
+
'[V\x16]*:*',
|
|
745
|
+
-- Hide relative numbers when neither linewise/blockwise mode is on
|
|
746
|
+
function() vim.wo.relativenumber = string.find(vim.fn.mode(), '^[V\22]') ~= nil end,
|
|
747
|
+
'Hide relative line numbers'
|
|
748
|
+
)
|
|
749
|
+
end
|
|
750
|
+
end
|
|
751
|
+
|
|
752
|
+
-- Utilities ------------------------------------------------------------------
|
|
753
|
+
H.error = function(msg) error('(mini.basics) ' .. msg, 0) end
|
|
754
|
+
|
|
755
|
+
H.check_type = function(name, val, ref, allow_nil)
|
|
756
|
+
if type(val) == ref or (ref == 'callable' and vim.is_callable(val)) or (allow_nil and val == nil) then return end
|
|
757
|
+
H.error(string.format('`%s` should be %s, not %s', name, ref, type(val)))
|
|
758
|
+
end
|
|
759
|
+
|
|
760
|
+
H.map = function(mode, lhs, rhs, opts)
|
|
761
|
+
if lhs == '' then return end
|
|
762
|
+
opts = vim.tbl_deep_extend('force', { silent = true }, opts or {})
|
|
763
|
+
vim.keymap.set(mode, lhs, rhs, opts)
|
|
764
|
+
end
|
|
765
|
+
|
|
766
|
+
if vim.fn.has('nvim-0.10') == 1 then
|
|
767
|
+
H.diagnostic_is_enabled = function(buf_id) return vim.diagnostic.is_enabled({ bufnr = buf_id }) end
|
|
768
|
+
else
|
|
769
|
+
H.diagnostic_is_enabled = function(buf_id) return not vim.diagnostic.is_disabled(buf_id) end
|
|
770
|
+
end
|
|
771
|
+
|
|
772
|
+
return MiniBasics
|