retrovim 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. package/.conda/retrovim.yaml +259 -0
  2. package/.conda/terax.icns +0 -0
  3. package/.conda/terax.ico +0 -0
  4. package/.conda/terax.png +0 -0
  5. package/.github/workflows/release.yml +95 -0
  6. package/.gitmodules +3 -0
  7. package/.npm/kanata_touchcursor.js +28 -0
  8. package/.npm/nvim.js +26 -0
  9. package/.npm/yazi.js +26 -0
  10. package/.npm/zsh.js +17 -0
  11. package/.pip/kanata_touchcursor/__init__.py +28 -0
  12. package/.pip/nvim/__init__.py +31 -0
  13. package/.pip/yazi/__init__.py +31 -0
  14. package/.pip/zsh/__init__.py +22 -0
  15. package/CHANGELOG.md +26 -0
  16. package/LICENSE +674 -0
  17. package/README.md +336 -0
  18. package/kanata/touchcursor.kbd +164 -0
  19. package/nvim/init.lua +813 -0
  20. package/nvim/plugins/mini.nvim/.github/DISCUSSION_TEMPLATE/q-a.yml +72 -0
  21. package/nvim/plugins/mini.nvim/.github/ISSUE_TEMPLATE/bug-report.yml +136 -0
  22. package/nvim/plugins/mini.nvim/.github/ISSUE_TEMPLATE/config.yml +5 -0
  23. package/nvim/plugins/mini.nvim/.github/ISSUE_TEMPLATE/feature-request.yml +75 -0
  24. package/nvim/plugins/mini.nvim/.github/PULL_REQUEST_TEMPLATE.md +2 -0
  25. package/nvim/plugins/mini.nvim/.github/workflows/quality-control.yml +150 -0
  26. package/nvim/plugins/mini.nvim/.pre-commit-config.yaml +20 -0
  27. package/nvim/plugins/mini.nvim/.stylua.toml +7 -0
  28. package/nvim/plugins/mini.nvim/.styluaignore +1 -0
  29. package/nvim/plugins/mini.nvim/CHANGELOG.md +1894 -0
  30. package/nvim/plugins/mini.nvim/CODE_OF_CONDUCT.md +132 -0
  31. package/nvim/plugins/mini.nvim/CONTRIBUTING.md +331 -0
  32. package/nvim/plugins/mini.nvim/LICENSE +21 -0
  33. package/nvim/plugins/mini.nvim/MAINTAINING.md +330 -0
  34. package/nvim/plugins/mini.nvim/Makefile +51 -0
  35. package/nvim/plugins/mini.nvim/README.md +261 -0
  36. package/nvim/plugins/mini.nvim/TESTING.md +1011 -0
  37. package/nvim/plugins/mini.nvim/benchmarks/starter/README.md +35 -0
  38. package/nvim/plugins/mini.nvim/benchmarks/starter/benchmark.sh +56 -0
  39. package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_dashboard-alpha.lua +21 -0
  40. package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_dashboard-original.lua +17 -0
  41. package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_dashboard-starter.lua +18 -0
  42. package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_empty.lua +4 -0
  43. package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_starter-default.lua +7 -0
  44. package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_startify-alpha.lua +10 -0
  45. package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_startify-original.lua +7 -0
  46. package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_startify-starter.lua +20 -0
  47. package/nvim/plugins/mini.nvim/benchmarks/starter/install.sh +10 -0
  48. package/nvim/plugins/mini.nvim/benchmarks/starter/make_summary.py +68 -0
  49. package/nvim/plugins/mini.nvim/benchmarks/starter/startup-summary.md +10 -0
  50. package/nvim/plugins/mini.nvim/colors/miniautumn.lua +55 -0
  51. package/nvim/plugins/mini.nvim/colors/minicyan.lua +95 -0
  52. package/nvim/plugins/mini.nvim/colors/minischeme.lua +95 -0
  53. package/nvim/plugins/mini.nvim/colors/minispring.lua +53 -0
  54. package/nvim/plugins/mini.nvim/colors/minisummer.lua +49 -0
  55. package/nvim/plugins/mini.nvim/colors/miniwinter.lua +51 -0
  56. package/nvim/plugins/mini.nvim/colors/randomhue.lua +16 -0
  57. package/nvim/plugins/mini.nvim/doc/mini-ai.txt +889 -0
  58. package/nvim/plugins/mini.nvim/doc/mini-align.txt +923 -0
  59. package/nvim/plugins/mini.nvim/doc/mini-animate.txt +937 -0
  60. package/nvim/plugins/mini.nvim/doc/mini-base16.txt +285 -0
  61. package/nvim/plugins/mini.nvim/doc/mini-basics.txt +359 -0
  62. package/nvim/plugins/mini.nvim/doc/mini-bracketed.txt +622 -0
  63. package/nvim/plugins/mini.nvim/doc/mini-bufremove.txt +123 -0
  64. package/nvim/plugins/mini.nvim/doc/mini-clue.txt +760 -0
  65. package/nvim/plugins/mini.nvim/doc/mini-cmdline.txt +392 -0
  66. package/nvim/plugins/mini.nvim/doc/mini-colors.txt +880 -0
  67. package/nvim/plugins/mini.nvim/doc/mini-comment.txt +230 -0
  68. package/nvim/plugins/mini.nvim/doc/mini-completion.txt +477 -0
  69. package/nvim/plugins/mini.nvim/doc/mini-cursorword.txt +105 -0
  70. package/nvim/plugins/mini.nvim/doc/mini-deps.txt +590 -0
  71. package/nvim/plugins/mini.nvim/doc/mini-diff.txt +661 -0
  72. package/nvim/plugins/mini.nvim/doc/mini-doc.txt +434 -0
  73. package/nvim/plugins/mini.nvim/doc/mini-extra.txt +856 -0
  74. package/nvim/plugins/mini.nvim/doc/mini-files.txt +1018 -0
  75. package/nvim/plugins/mini.nvim/doc/mini-fuzzy.txt +160 -0
  76. package/nvim/plugins/mini.nvim/doc/mini-git.txt +425 -0
  77. package/nvim/plugins/mini.nvim/doc/mini-hipatterns.txt +489 -0
  78. package/nvim/plugins/mini.nvim/doc/mini-hues.txt +420 -0
  79. package/nvim/plugins/mini.nvim/doc/mini-icons.txt +508 -0
  80. package/nvim/plugins/mini.nvim/doc/mini-indentscope.txt +485 -0
  81. package/nvim/plugins/mini.nvim/doc/mini-input.txt +932 -0
  82. package/nvim/plugins/mini.nvim/doc/mini-jump.txt +202 -0
  83. package/nvim/plugins/mini.nvim/doc/mini-jump2d.txt +525 -0
  84. package/nvim/plugins/mini.nvim/doc/mini-keymap.txt +449 -0
  85. package/nvim/plugins/mini.nvim/doc/mini-map.txt +717 -0
  86. package/nvim/plugins/mini.nvim/doc/mini-misc.txt +431 -0
  87. package/nvim/plugins/mini.nvim/doc/mini-move.txt +181 -0
  88. package/nvim/plugins/mini.nvim/doc/mini-notify.txt +434 -0
  89. package/nvim/plugins/mini.nvim/doc/mini-nvim.txt +431 -0
  90. package/nvim/plugins/mini.nvim/doc/mini-operators.txt +472 -0
  91. package/nvim/plugins/mini.nvim/doc/mini-pairs.txt +346 -0
  92. package/nvim/plugins/mini.nvim/doc/mini-pick.txt +1535 -0
  93. package/nvim/plugins/mini.nvim/doc/mini-sessions.txt +239 -0
  94. package/nvim/plugins/mini.nvim/doc/mini-snippets.txt +1291 -0
  95. package/nvim/plugins/mini.nvim/doc/mini-splitjoin.txt +536 -0
  96. package/nvim/plugins/mini.nvim/doc/mini-starter.txt +618 -0
  97. package/nvim/plugins/mini.nvim/doc/mini-statusline.txt +361 -0
  98. package/nvim/plugins/mini.nvim/doc/mini-surround.txt +863 -0
  99. package/nvim/plugins/mini.nvim/doc/mini-tabline.txt +151 -0
  100. package/nvim/plugins/mini.nvim/doc/mini-test.txt +966 -0
  101. package/nvim/plugins/mini.nvim/doc/mini-trailspace.txt +91 -0
  102. package/nvim/plugins/mini.nvim/doc/mini-visits.txt +937 -0
  103. package/nvim/plugins/mini.nvim/logo.png +0 -0
  104. package/nvim/plugins/mini.nvim/lua/mini/ai.lua +2244 -0
  105. package/nvim/plugins/mini.nvim/lua/mini/align.lua +2076 -0
  106. package/nvim/plugins/mini.nvim/lua/mini/animate.lua +2127 -0
  107. package/nvim/plugins/mini.nvim/lua/mini/base16.lua +1752 -0
  108. package/nvim/plugins/mini.nvim/lua/mini/basics.lua +772 -0
  109. package/nvim/plugins/mini.nvim/lua/mini/bracketed.lua +2013 -0
  110. package/nvim/plugins/mini.nvim/lua/mini/bufremove.lua +283 -0
  111. package/nvim/plugins/mini.nvim/lua/mini/clue.lua +2096 -0
  112. package/nvim/plugins/mini.nvim/lua/mini/cmdline.lua +1182 -0
  113. package/nvim/plugins/mini.nvim/lua/mini/colors.lua +2483 -0
  114. package/nvim/plugins/mini.nvim/lua/mini/comment.lua +586 -0
  115. package/nvim/plugins/mini.nvim/lua/mini/completion.lua +2094 -0
  116. package/nvim/plugins/mini.nvim/lua/mini/cursorword.lua +311 -0
  117. package/nvim/plugins/mini.nvim/lua/mini/deps.lua +1660 -0
  118. package/nvim/plugins/mini.nvim/lua/mini/diff.lua +1938 -0
  119. package/nvim/plugins/mini.nvim/lua/mini/doc.lua +1371 -0
  120. package/nvim/plugins/mini.nvim/lua/mini/extra.lua +2290 -0
  121. package/nvim/plugins/mini.nvim/lua/mini/files.lua +3145 -0
  122. package/nvim/plugins/mini.nvim/lua/mini/fuzzy.lua +356 -0
  123. package/nvim/plugins/mini.nvim/lua/mini/git.lua +1737 -0
  124. package/nvim/plugins/mini.nvim/lua/mini/hipatterns.lua +1042 -0
  125. package/nvim/plugins/mini.nvim/lua/mini/hues.lua +2088 -0
  126. package/nvim/plugins/mini.nvim/lua/mini/icons.lua +2254 -0
  127. package/nvim/plugins/mini.nvim/lua/mini/indentscope.lua +1158 -0
  128. package/nvim/plugins/mini.nvim/lua/mini/init.lua +427 -0
  129. package/nvim/plugins/mini.nvim/lua/mini/input.lua +2183 -0
  130. package/nvim/plugins/mini.nvim/lua/mini/jump.lua +609 -0
  131. package/nvim/plugins/mini.nvim/lua/mini/jump2d.lua +1244 -0
  132. package/nvim/plugins/mini.nvim/lua/mini/keymap.lua +880 -0
  133. package/nvim/plugins/mini.nvim/lua/mini/map.lua +1709 -0
  134. package/nvim/plugins/mini.nvim/lua/mini/misc.lua +969 -0
  135. package/nvim/plugins/mini.nvim/lua/mini/move.lua +509 -0
  136. package/nvim/plugins/mini.nvim/lua/mini/notify.lua +938 -0
  137. package/nvim/plugins/mini.nvim/lua/mini/operators.lua +1349 -0
  138. package/nvim/plugins/mini.nvim/lua/mini/pairs.lua +657 -0
  139. package/nvim/plugins/mini.nvim/lua/mini/pick.lua +3876 -0
  140. package/nvim/plugins/mini.nvim/lua/mini/sessions.lua +689 -0
  141. package/nvim/plugins/mini.nvim/lua/mini/snippets.lua +2828 -0
  142. package/nvim/plugins/mini.nvim/lua/mini/splitjoin.lua +1132 -0
  143. package/nvim/plugins/mini.nvim/lua/mini/starter.lua +1599 -0
  144. package/nvim/plugins/mini.nvim/lua/mini/statusline.lua +686 -0
  145. package/nvim/plugins/mini.nvim/lua/mini/surround.lua +2388 -0
  146. package/nvim/plugins/mini.nvim/lua/mini/tabline.lua +564 -0
  147. package/nvim/plugins/mini.nvim/lua/mini/test.lua +2516 -0
  148. package/nvim/plugins/mini.nvim/lua/mini/trailspace.lua +215 -0
  149. package/nvim/plugins/mini.nvim/lua/mini/visits.lua +1577 -0
  150. package/nvim/plugins/mini.nvim/readmes/mini-ai.md +190 -0
  151. package/nvim/plugins/mini.nvim/readmes/mini-align.md +203 -0
  152. package/nvim/plugins/mini.nvim/readmes/mini-animate.md +214 -0
  153. package/nvim/plugins/mini.nvim/readmes/mini-base16.md +198 -0
  154. package/nvim/plugins/mini.nvim/readmes/mini-basics.md +184 -0
  155. package/nvim/plugins/mini.nvim/readmes/mini-bracketed.md +193 -0
  156. package/nvim/plugins/mini.nvim/readmes/mini-bufremove.md +139 -0
  157. package/nvim/plugins/mini.nvim/readmes/mini-clue.md +260 -0
  158. package/nvim/plugins/mini.nvim/readmes/mini-cmdline.md +183 -0
  159. package/nvim/plugins/mini.nvim/readmes/mini-colors.md +169 -0
  160. package/nvim/plugins/mini.nvim/readmes/mini-comment.md +183 -0
  161. package/nvim/plugins/mini.nvim/readmes/mini-completion.md +217 -0
  162. package/nvim/plugins/mini.nvim/readmes/mini-cursorword.md +137 -0
  163. package/nvim/plugins/mini.nvim/readmes/mini-deps.md +271 -0
  164. package/nvim/plugins/mini.nvim/readmes/mini-diff.md +289 -0
  165. package/nvim/plugins/mini.nvim/readmes/mini-doc.md +198 -0
  166. package/nvim/plugins/mini.nvim/readmes/mini-extra.md +158 -0
  167. package/nvim/plugins/mini.nvim/readmes/mini-files.md +247 -0
  168. package/nvim/plugins/mini.nvim/readmes/mini-fuzzy.md +134 -0
  169. package/nvim/plugins/mini.nvim/readmes/mini-git.md +168 -0
  170. package/nvim/plugins/mini.nvim/readmes/mini-hipatterns.md +176 -0
  171. package/nvim/plugins/mini.nvim/readmes/mini-hues.md +285 -0
  172. package/nvim/plugins/mini.nvim/readmes/mini-icons.md +183 -0
  173. package/nvim/plugins/mini.nvim/readmes/mini-indentscope.md +191 -0
  174. package/nvim/plugins/mini.nvim/readmes/mini-input.md +163 -0
  175. package/nvim/plugins/mini.nvim/readmes/mini-jump.md +161 -0
  176. package/nvim/plugins/mini.nvim/readmes/mini-jump2d.md +197 -0
  177. package/nvim/plugins/mini.nvim/readmes/mini-keymap.md +205 -0
  178. package/nvim/plugins/mini.nvim/readmes/mini-map.md +191 -0
  179. package/nvim/plugins/mini.nvim/readmes/mini-misc.md +145 -0
  180. package/nvim/plugins/mini.nvim/readmes/mini-move.md +163 -0
  181. package/nvim/plugins/mini.nvim/readmes/mini-notify.md +175 -0
  182. package/nvim/plugins/mini.nvim/readmes/mini-operators.md +193 -0
  183. package/nvim/plugins/mini.nvim/readmes/mini-pairs.md +158 -0
  184. package/nvim/plugins/mini.nvim/readmes/mini-pick.md +340 -0
  185. package/nvim/plugins/mini.nvim/readmes/mini-sessions.md +164 -0
  186. package/nvim/plugins/mini.nvim/readmes/mini-snippets.md +373 -0
  187. package/nvim/plugins/mini.nvim/readmes/mini-splitjoin.md +194 -0
  188. package/nvim/plugins/mini.nvim/readmes/mini-starter.md +176 -0
  189. package/nvim/plugins/mini.nvim/readmes/mini-statusline.md +155 -0
  190. package/nvim/plugins/mini.nvim/readmes/mini-surround.md +190 -0
  191. package/nvim/plugins/mini.nvim/readmes/mini-tabline.md +156 -0
  192. package/nvim/plugins/mini.nvim/readmes/mini-test.md +175 -0
  193. package/nvim/plugins/mini.nvim/readmes/mini-trailspace.md +137 -0
  194. package/nvim/plugins/mini.nvim/readmes/mini-visits.md +243 -0
  195. package/nvim/plugins/mini.nvim/scripts/dual_log.sh +13 -0
  196. package/nvim/plugins/mini.nvim/scripts/dual_push.sh +15 -0
  197. package/nvim/plugins/mini.nvim/scripts/dual_release.sh +102 -0
  198. package/nvim/plugins/mini.nvim/scripts/dual_sync.sh +115 -0
  199. package/nvim/plugins/mini.nvim/scripts/init-deps-example.lua +59 -0
  200. package/nvim/plugins/mini.nvim/scripts/lint-filename-length.sh +16 -0
  201. package/nvim/plugins/mini.nvim/scripts/lintcommit-ci.sh +18 -0
  202. package/nvim/plugins/mini.nvim/scripts/lintcommit.lua +393 -0
  203. package/nvim/plugins/mini.nvim/scripts/minidoc.lua +57 -0
  204. package/nvim/plugins/mini.nvim/scripts/minimal_init.lua +28 -0
  205. package/nvim/plugins/mini.nvim/scripts/minitest.lua +4 -0
  206. package/package.json +16 -0
  207. package/pyproject.toml +43 -0
  208. package/yazi/init.lua +12 -0
  209. package/yazi/keymap.toml +114 -0
  210. package/yazi/lesskey +5 -0
  211. package/yazi/plugins/bookmarks.yazi/main.lua +86 -0
  212. package/yazi/plugins/cd-git-root.yazi/main.lua +31 -0
  213. package/yazi/plugins/smart-enter.yazi/main.lua +11 -0
  214. package/yazi/theme.toml +26 -0
  215. package/yazi/yazi.toml +15 -0
  216. package/zsh/.zshrc +145 -0
  217. package/zsh/starship.toml +20 -0
  218. package/zsh/zsh-patina.toml +2 -0
@@ -0,0 +1,863 @@
1
+ *mini.surround* Surround actions
2
+
3
+ MIT License Copyright (c) 2021 Evgeni Chasnovski
4
+
5
+ ------------------------------------------------------------------------------
6
+ *MiniSurround*
7
+ Fast and feature-rich surrounding. Can be configured to have experience
8
+ similar to [tpope/vim-surround](https://github.com/tpope/vim-surround)
9
+ (see |MiniSurround-vim-surround-config|).
10
+
11
+ Features:
12
+ - Actions (text editing actions are dot-repeatable out of the box and
13
+ respect |[count]|) with configurable mappings:
14
+ - Add surrounding with `sa` (in visual mode or on motion).
15
+ - Delete surrounding with `sd`.
16
+ - Replace surrounding with `sr`.
17
+ - Find surrounding with `sf` or `sF` (move cursor right or left).
18
+ - Highlight surrounding with `sh`.
19
+
20
+ - Surrounding is identified by a single character as both "input" (in
21
+ `delete` and `replace` start, `find`, and `highlight`) and "output" (in
22
+ `add` and `replace` end):
23
+ - `f` - function call (string of alphanumeric symbols or `_` or `.`
24
+ followed by balanced `()`). In "input" finds function call, in
25
+ "output" prompts user to enter function name.
26
+ - `t` - tag. In "input" finds tag with same identifier, in "output"
27
+ prompts user to enter tag name with possible attributes.
28
+ - All symbols in brackets `()`, `[]`, `{}`, `<>`. In "input" represents
29
+ balanced brackets (open - with whitespace pad, close - without), in
30
+ "output" - left and right parts of brackets.
31
+ - `?` - interactive. Prompts user to enter left and right parts.
32
+ - All other single character identifiers (supported by |getcharstr()|)
33
+ represent surrounding with identical left and right parts.
34
+
35
+ - Configurable search methods to find not only covering but possibly next,
36
+ previous, or nearest surrounding. See more in |MiniSurround.config|.
37
+
38
+ - All actions involving finding surrounding (delete, replace, find,
39
+ highlight) can be used with suffix that changes search method to find
40
+ previous/last. See more in |MiniSurround.config|.
41
+
42
+ Known issues which won't be resolved:
43
+ - Search for surrounding is done using Lua patterns (regex-like approach).
44
+ So certain amount of false positives should be expected.
45
+
46
+ - When searching for "input" surrounding, there is no distinction if it is
47
+ inside string or comment. So in this case there will be not proper match
48
+ for a function call: `f(a = ")", b = 1)`.
49
+
50
+ - Tags are searched using regex-like methods, so issues are inevitable.
51
+ Overall it is pretty good, but certain cases won't work. Like self-nested
52
+ tags won't match correctly on both ends: `<a><a></a></a>`.
53
+
54
+ # Setup ~
55
+
56
+ This module needs a setup with `require('mini.surround').setup({})`
57
+ (replace `{}` with your `config` table). It will create global Lua table
58
+ `MiniSurround` which you can use for scripting or manually (with
59
+ `:lua MiniSurround.*`).
60
+
61
+ See |MiniSurround.config| for `config` structure and default values.
62
+
63
+ You can override runtime config settings locally to buffer inside
64
+ `vim.b.minisurround_config` which should have same structure as
65
+ `MiniSurround.config`. See |mini.nvim-buffer-local-config| for more details.
66
+
67
+ To stop module from showing non-error feedback, set `config.silent = true`.
68
+
69
+ # Example usage ~
70
+
71
+ Regular mappings:
72
+ - `saiw)` - add (`sa`) for inner word (`iw`) parenthesis (`)`).
73
+ - `saiw?[[<CR>]]<CR>` - add (`sa`) for inner word (`iw`) interactive
74
+ surrounding (`?`): `[[` for left and `]]` for right.
75
+ - `2sdf` - delete (`sd`) second (`2`) surrounding function call (`f`).
76
+ - `sr)tdiv<CR>` - replace (`sr`) surrounding parenthesis (`)`) with tag
77
+ (`t`) with identifier `div` (`div<CR>` in command line prompt).
78
+ - `sff` - find right (`sf`) part of surrounding function call (`f`).
79
+ - `sh}` - highlight (`sh`) for a brief period of time surrounding curly
80
+ brackets (`}`).
81
+
82
+ Extended mappings (temporary force "prev"/"next" search methods):
83
+ - `sdnf` - delete (`sd`) next (`n`) function call (`f`).
84
+ - `srlf(` - replace (`sr`) last (`l`) function call (`f`) with padded
85
+ bracket (`(`).
86
+ - `2sfnt` - find (`sf`) second (`2`) next (`n`) tag (`t`).
87
+ - `2shl}` - highlight (`sh`) last (`l`) second (`2`) curly bracket (`}`).
88
+
89
+ # Comparisons ~
90
+
91
+ - [tpope/vim-surround](https://github.com/tpope/vim-surround):
92
+ - `vim-surround` has completely different, with other focus set of
93
+ default mappings, while |mini.surround| has a more coherent set.
94
+ - |mini.surround| supports dot-repeat, customized search path (see
95
+ |MiniSurround.config|), customized specifications (see
96
+ |MiniSurround-surrounding-specification|) allowing usage of tree-sitter
97
+ queries (see |MiniSurround.gen_spec.input.treesitter()|),
98
+ highlighting and finding surrounding, "last"/"next" extended
99
+ mappings. While `vim-surround` does not.
100
+ - [machakann/vim-sandwich](https://github.com/machakann/vim-sandwich):
101
+ - Both have same keybindings for common actions (add, delete, replace).
102
+ - Otherwise same differences as with `tpope/vim-surround` (except
103
+ dot-repeat because `vim-sandwich` supports it).
104
+ - [kylechui/nvim-surround](https://github.com/kylechui/nvim-surround):
105
+ - `nvim-surround` is designed after `tpope/vim-surround` with same
106
+ default mappings and logic, while |mini.surround| has mappings
107
+ similar to `machakann/vim-sandwich`.
108
+ - |mini.surround| has more flexible customization of input surrounding
109
+ (with composed patterns, region pair(s), search methods).
110
+ - |mini.surround| supports |[count]| in both input and output
111
+ surrounding (see |MiniSurround-count-with-actions|) while
112
+ `nvim-surround` doesn't.
113
+ - |mini.surround| supports "last"/"next" extended mappings.
114
+ - |mini.ai|:
115
+ - Both use similar logic for finding target: textobject in |mini.ai|
116
+ and surrounding pair in |mini.surround|. While |mini.ai| uses
117
+ extraction pattern for separate `a` and `i` textobjects,
118
+ |mini.surround| uses it to select left and right surroundings
119
+ (basically a difference between `a` and `i` textobjects).
120
+ - Some builtin specifications are slightly different:
121
+ - Quotes in |mini.ai| are balanced, in |mini.surround| they are not.
122
+ - The |mini.surround| doesn't have argument surrounding.
123
+ - Default behavior in |mini.ai| selects one of the edges into `a`
124
+ textobject, while |mini.surround| - both.
125
+
126
+ # Highlight groups ~
127
+ *MiniSurround-hl-groups*
128
+
129
+ - `MiniSurround` - highlighting of requested surrounding.
130
+
131
+ To change any highlight group, set it directly with |nvim_set_hl()|.
132
+
133
+ # Disabling ~
134
+
135
+ To disable, set `vim.g.minisurround_disable` (globally) or
136
+ `vim.b.minisurround_disable` (for a buffer) to `true`. Considering high
137
+ number of different scenarios and customization intentions, writing exact
138
+ rules for disabling module's functionality is left to user. See
139
+ |mini.nvim-disabling-recipes| for common recipes.
140
+
141
+ ------------------------------------------------------------------------------
142
+ *MiniSurround-builtin-surroundings*
143
+ This table describes all builtin surroundings along with what they
144
+ represent. Explanation:
145
+ - `Key` represents the surrounding identifier: single character which should
146
+ be typed after action mappings (see "Mappings" in |MiniSurround.config|).
147
+ - `Name` is a description of surrounding.
148
+ - `Example line` contains a string for which examples are constructed. The
149
+ `*` denotes the cursor position over `a` character.
150
+ - `Delete` shows the result of typing `sd` followed by surrounding identifier.
151
+ It aims to demonstrate "input" surrounding which is also used in replace
152
+ with `sr` (surrounding id is typed first), highlight with `sh`, find with
153
+ `sf` and `sF`.
154
+ - `Replace` shows the result of typing `sr!` followed by surrounding
155
+ identifier (with possible follow up from user). It aims to demonstrate
156
+ "output" surrounding which is also used in adding with `sa` (followed by
157
+ textobject/motion or in Visual mode).
158
+
159
+ Example: typing `sd)` with cursor on `*` (covers `a` character) changes line
160
+ `!( *a (bb) )!` into `! aa (bb) !`. Typing `sr!)` changes same initial line
161
+ into `(( aa (bb) ))`.
162
+ >
163
+ ┌───┬───────────────┬───────────────┬─────────────┬─────────────────┐
164
+ │Key│ Name │ Example line │ Delete │ Replace │
165
+ ├───┴───────────────┴───────────────┴─────────────┴─────────────────┤
166
+ ├┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┤
167
+ │ ( │ Balanced () │ !( *a (bb) )! │ !aa (bb)! │ ( ( aa (bb) ) ) │
168
+ │ [ │ Balanced [] │ ![ *a [bb] ]! │ !aa [bb]! │ [ [ aa [bb] ] ] │
169
+ │ { │ Balanced {} │ !{ *a {bb} }! │ !aa {bb}! │ { { aa {bb} } } │
170
+ │ < │ Balanced <> │ !< *a <bb> >! │ !aa <bb>! │ < < aa <bb> > > │
171
+ ├┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┤
172
+ │ ) │ Balanced () │ !( *a (bb) )! │ ! aa (bb) ! │ (( aa (bb) )) │
173
+ │ ] │ Balanced [] │ ![ *a [bb] ]! │ ! aa [bb] ! │ [[ aa [bb] ]] │
174
+ │ } │ Balanced {} │ !{ *a {bb} }! │ ! aa {bb} ! │ {{ aa {bb} }} │
175
+ │ > │ Balanced <> │ !< *a <bb> >! │ ! aa <bb> ! │ << aa <bb> >> │
176
+ │ b │ Alias for │ !( *a {bb} )! │ ! aa {bb} ! │ (( aa {bb} )) │
177
+ │ │ ), ], or } │ │ │ │
178
+ ├┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┤
179
+ │ q │ Alias for │ !'aa'*a'aa'! │ !'aaaaaa'! │ "'aa'aa'aa'" │
180
+ │ │ ", ', or ` │ │ │ │
181
+ ├┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┤
182
+ │ ? │ User prompt │ !e * o! │ ! a ! │ ee a oo │
183
+ │ │(typed e and o)│ │ │ │
184
+ ├┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┤
185
+ │ t │ Tag │ !<x>*</x>! │ !a! │ <y><x>a</x></y> │
186
+ │ │ │ │ │ (typed y) │
187
+ ├┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┤
188
+ │ f │ Function call │ !f(*a, bb)! │ !aa, bb! │ g(f(*a, bb)) │
189
+ │ │ │ │ │ (typed g) │
190
+ ├┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┤
191
+ │ │ Default │ !_a*a_! │ !aaa! │ __aaa__ │
192
+ │ │ (typed _) │ │ │ │
193
+ └┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┘
194
+ <
195
+ Notes:
196
+ - All examples assume default `config.search_method`.
197
+ - Open brackets differ from close brackets by how they treat inner edge
198
+ whitespace: open includes it left and right parts, close does not.
199
+ - Output value of `b` alias is same as `)`. For `q` alias - same as `"`.
200
+ - Default surrounding is activated for all characters which are not
201
+ configured surrounding identifiers. Notes:
202
+ - Due to special handling of underlying `x.-x` Lua pattern
203
+ (see |MiniSurround-search-algorithm|), it doesn't really support
204
+ non-trivial `[count]` for "cover" search method.
205
+ - When cursor is exactly on the identifier character while there are
206
+ two matching candidates on both left and right, the one resulting in
207
+ region with smaller width is preferred.
208
+
209
+ ------------------------------------------------------------------------------
210
+ *MiniSurround-glossary*
211
+ Note: this is similar to |MiniAi-glossary|.
212
+
213
+ REGION ~
214
+ Table representing region in a buffer. Fields: <from> and <to> for
215
+ inclusive start and end positions (<to> might be `nil` to describe empty
216
+ region). Each position is also a table with line <line> and column <col>
217
+ (both start at 1). Examples: >lua
218
+
219
+ { from = { line = 1, col = 1 }, to = { line = 2, col = 1 } }
220
+
221
+ -- Empty region
222
+ { from = { line = 10, col = 10 } }
223
+ <
224
+ REGION PAIR ~
225
+ Table representing regions for left and right surroundings. Fields: <left>
226
+ and <right> with regions. Example: >lua
227
+
228
+ {
229
+ left = { from = { line = 1, col = 1 }, to = { line = 1, col = 1 } },
230
+ right = { from = { line = 1, col = 3 } },
231
+ }
232
+ <
233
+ PATTERN ~
234
+ String describing Lua pattern.
235
+
236
+ SPAN ~
237
+ Interval inside a string (end-exclusive). Like [1, 5). Equal `from` and `to` edges
238
+ describe empty span at that point.
239
+
240
+ Span `A = [a1, a2)` covers `B = [b1, b2)` if every element of `B` is within
241
+ `A` (`a1 <= b < a2`). It also is described as "B is nested inside A".
242
+
243
+ NESTED PATTERN ~
244
+ Array of patterns aimed to describe nested spans.
245
+
246
+ SPAN MATCHES NESTED PATTERN ~
247
+ If there is a sequence of consecutively nested spans each matching
248
+ corresponding pattern within substring of previous span (or input string
249
+ for first span). Example: >lua
250
+
251
+ -- Nested patterns for balanced `()` with inner space
252
+ { '%b()', '^. .* .$' }
253
+
254
+ -- Example input string (with columns underneath for easier reading):
255
+ "( ( () ( ) ) )"
256
+ -- 12345678901234
257
+ <
258
+ Here are all matching spans [1, 15) and [3, 13). Both [5, 7) and [8, 10)
259
+ match first pattern but not second. All other combinations of `(` and `)`
260
+ don't match first pattern (not balanced).
261
+
262
+ COMPOSED PATTERN ~
263
+ Array with each element describing possible pattern (or array of them) at
264
+ that place. Composed pattern basically defines all possible combinations of
265
+ nested pattern (their cartesian product). Examples:
266
+
267
+ 1. Either balanced `()` or balanced `[]` but both with inner edge space: >lua
268
+
269
+ -- Composed pattern
270
+ { { '%b()', '%b[]' }, '^. .* .$' }
271
+
272
+ -- Composed pattern expanded into equivalent array of nested patterns
273
+ { '%b()', '^. .* .$' } -- and
274
+ { '%b[]', '^. .* .$' }
275
+ <
276
+ 2. Either "balanced `()` with inner edge space" or "balanced `[]` with no
277
+ inner edge space", both with 5 or more characters: >lua
278
+
279
+ -- Composed pattern
280
+ { { { '%b()', '^. .* .$' }, { '%b[]', '^.[^ ].*[^ ].$' } }, '.....' }
281
+
282
+ -- Composed pattern expanded into equivalent array of nested patterns
283
+ { '%b()', '^. .* .$', '.....' } -- and
284
+ { '%b[]', '^.[^ ].*[^ ].$', '.....' }
285
+ <
286
+ SPAN MATCHES COMPOSED PATTERN ~
287
+ If it matches at least one nested pattern from expanded composed pattern.
288
+
289
+ ------------------------------------------------------------------------------
290
+ *MiniSurround-surrounding-specification*
291
+ Surround specification is a table with keys:
292
+ - <input> - defines how to find and extract surrounding for "input"
293
+ operations (like `delete`). See more in "Input surrounding" section.
294
+ - <output> - defines what to add on left and right for "output" operations
295
+ (like `add`). See more in "Output surrounding" section.
296
+
297
+ Example of surround info for builtin `)` identifier: >lua
298
+
299
+ {
300
+ input = { '%b()', '^.().*().$' },
301
+ output = { left = '(', right = ')' }
302
+ }
303
+ <
304
+ # Input surrounding ~
305
+
306
+ Specification for input surrounding has a structure of composed pattern
307
+ (see |MiniSurround-glossary|) with two differences:
308
+ - Last pattern(s) should have two or four empty capture groups denoting
309
+ how the last string should be processed to extract surrounding parts:
310
+ - Two captures represent left part from start of string to first
311
+ capture and right part - from second capture to end of string.
312
+ Example: `a()b()c` defines left surrounding as `a`, right - `c`.
313
+ - Four captures define left part inside captures 1 and 2, right part -
314
+ inside captures 3 and 4. Example: `a()()b()c()` defines left part as
315
+ empty, right part as `c`.
316
+ - Allows callable objects (see |vim.is_callable()|) in certain places
317
+ (enables more complex surroundings in exchange of increase in configuration
318
+ complexity and computations):
319
+ - If specification itself is a callable, it will be called without
320
+ arguments and should return one of:
321
+ - Composed pattern. Useful for implementing user input. Example of
322
+ simplified variant of input surrounding for function call with
323
+ name taken from user prompt: >lua
324
+
325
+ function()
326
+ local left_edge = vim.pesc(vim.fn.input('Function name: '))
327
+ return { left_edge .. '%b()', '^.-%(().*()%)$' }
328
+ end
329
+ <
330
+ - Single region pair (see |MiniSurround-glossary|). Useful to allow
331
+ full control over surrounding. Will be taken as is. Example of
332
+ returning first and last lines of a buffer: >lua
333
+
334
+ function()
335
+ local n_lines = vim.fn.line('$')
336
+ return {
337
+ left = {
338
+ from = { line = 1, col = 1 },
339
+ to = { line = 1, col = vim.fn.getline(1):len() }
340
+ },
341
+ right = {
342
+ from = { line = n_lines, col = 1 },
343
+ to = { line = n_lines, col = vim.fn.getline(n_lines):len() }
344
+ },
345
+ }
346
+ end
347
+ <
348
+ - Array of region pairs. Useful for incorporating other instruments,
349
+ like treesitter (see |MiniSurround.gen_spec.input.treesitter()|). The
350
+ best region pair will be picked in the same manner as with composed
351
+ pattern (respecting options `n_lines`, `search_method`, etc.) using
352
+ output region (from start of left region to end of right region).
353
+ Example using edges of "best" line with display width more than 80: >lua
354
+
355
+ function()
356
+ local make_line_region_pair = function(n)
357
+ local left = { line = n, col = 1 }
358
+ local right = { line = n, col = vim.fn.getline(n):len() }
359
+ return {
360
+ left = { from = left, to = left },
361
+ right = { from = right, to = right },
362
+ }
363
+ end
364
+
365
+ local res = {}
366
+ for i = 1, vim.fn.line('$') do
367
+ if vim.fn.getline(i):len() > 80 then
368
+ table.insert(res, make_line_region_pair(i))
369
+ end
370
+ end
371
+ return res
372
+ end
373
+ <
374
+ - If there is a callable instead of assumed string pattern, it is expected
375
+ to have signature `(line, init)` and behave like `pattern:find()`.
376
+ It should return two numbers representing span in `line` next after
377
+ or at `init` (`nil` if there is no such span).
378
+ !IMPORTANT NOTE!: it means that output's `from` shouldn't be strictly
379
+ to the left of `init` (it will lead to infinite loop). Not allowed as
380
+ last item (as it should be pattern with captures).
381
+ Example of matching only balanced parenthesis with big enough width: >lua
382
+
383
+ {
384
+ '%b()',
385
+ function(s, init)
386
+ if init > 1 or s:len() < 5 then return end
387
+ return 1, s:len()
388
+ end,
389
+ '^.().*().$'
390
+ }
391
+ <
392
+ More examples: >lua
393
+
394
+ -- Pair of balanced brackets from set (used for builtin `b` identifier)
395
+ { { '%b()', '%b[]', '%b{}' }, '^.().*().$' }
396
+
397
+ -- Lua block string
398
+ { '%[%[().-()%]%]' }
399
+ <
400
+ See |MiniSurround.gen_spec| for function wrappers to create commonly used
401
+ surrounding specifications.
402
+
403
+ # Output surrounding ~
404
+
405
+ Specification for output can be either a table with <left> and <right> fields,
406
+ or a callable returning such table (will be called with no arguments).
407
+ Strings can contain new lines character "\n" to add multiline parts.
408
+
409
+ Examples: >lua
410
+
411
+ -- Lua block string
412
+ { left = '[[', right = ']]' }
413
+
414
+ -- Brackets on separate lines (indentation is not preserved)
415
+ { left = '(\n', right = '\n)' }
416
+
417
+ -- Function call
418
+ function()
419
+ local function_name = MiniSurround.user_input('Function name')
420
+ return { left = function_name .. '(', right = ')' }
421
+ end
422
+ <
423
+ ------------------------------------------------------------------------------
424
+ *MiniSurround-count-with-actions*
425
+ |[count]| is supported by all actions in the following ways:
426
+
427
+ - In add, two types of `[count]` is supported in Normal mode:
428
+ `[count1]sa[count2][textobject]`. The `[count1]` defines how many times
429
+ left and right parts of output surrounding will be repeated and `[count2]` is
430
+ used for textobject.
431
+ In Visual mode `[count]` is treated as `[count1]`.
432
+ Example: `2sa3aw)` and `v3aw2sa)` will result into textobject `3aw` being
433
+ surrounded by `((` and `))`.
434
+
435
+ - In delete/replace/find/highlight `[count]` means "find n-th surrounding
436
+ and execute operator on it".
437
+ Example: `2sd)` on line `(a(b(c)b)a)` with cursor on `c` will result into
438
+ `(ab(c)ba)` (and not in `(abcba)` if it would have meant "delete n times").
439
+
440
+ ------------------------------------------------------------------------------
441
+ *MiniSurround-search-algorithm*
442
+ Search for the input surrounding relies on these principles:
443
+ - Input surrounding specification is constructed based on surrounding
444
+ identifier (see |MiniSurround-surrounding-specification|).
445
+ - General search is done by converting some 2d buffer region (neighborhood
446
+ of reference region) into 1d string (each line is appended with `\n`).
447
+ Then search for a best span matching specification is done inside string
448
+ (see |MiniSurround-glossary|). After that, span is converted back into 2d
449
+ region. Note: first search is done inside reference region lines, and
450
+ only after that - inside its neighborhood within `config.n_lines` (see
451
+ |MiniSurround.config|).
452
+ - The best matching span is chosen by iterating over all spans matching
453
+ surrounding specification and comparing them with "current best".
454
+ Comparison also depends on reference region (tighter covering is better,
455
+ otherwise closer is better) and search method (if span is even considered).
456
+ - Extract pair of spans (for left and right regions in region pair) based
457
+ on extraction pattern (last item in nested pattern).
458
+ - For |[count]| greater than 1, steps are repeated with current best match
459
+ becoming reference region. One such additional step is also done if final
460
+ region is equal to reference region.
461
+
462
+ Notes:
463
+ - Iteration over all matched spans is done in depth-first fashion with
464
+ respect to nested pattern.
465
+ - It is guaranteed that span is compared only once.
466
+ - For the sake of increasing functionality, during iteration over all
467
+ matching spans, some Lua patterns in composed pattern are handled
468
+ specially.
469
+ - `%bxx` (`xx` is two identical characters). It denotes balanced pair
470
+ of identical characters and results into "paired" matches. For
471
+ example, `%b""` for `"aa" "bb"` would match `"aa"` and `"bb"`, but
472
+ not middle `" "`.
473
+ - `x.-y` (`x` and `y` are different strings). It results only in matches with
474
+ smallest width. For example, `e.-o` for `e e o o` will result only in
475
+ middle `e o`. Note: it has some implications for when parts have
476
+ quantifiers (like `+`, etc.), which usually can be resolved with
477
+ frontier pattern `%f[]`.
478
+
479
+ ------------------------------------------------------------------------------
480
+ *MiniSurround.setup()*
481
+ `MiniSurround.setup`({config})
482
+ Module setup
483
+
484
+ Parameters ~
485
+ {config} `(table|nil)` Module config table. See |MiniSurround.config|.
486
+
487
+ Usage ~
488
+ >lua
489
+ require('mini.surround').setup() -- use default config
490
+ -- OR
491
+ require('mini.surround').setup({}) -- replace {} with your config table
492
+ <
493
+ ------------------------------------------------------------------------------
494
+ *MiniSurround.config*
495
+ `MiniSurround.config`
496
+ Defaults ~
497
+ >lua
498
+ MiniSurround.config = {
499
+ -- Add custom surroundings to be used on top of builtin ones. For more
500
+ -- information with examples, see `:h MiniSurround.config`.
501
+ custom_surroundings = nil,
502
+
503
+ -- Duration (in ms) of highlight when calling `MiniSurround.highlight()`
504
+ highlight_duration = 500,
505
+
506
+ -- Module mappings. Use `''` (empty string) to disable one.
507
+ mappings = {
508
+ add = 'sa', -- Add surrounding in Normal and Visual modes
509
+ delete = 'sd', -- Delete surrounding
510
+ find = 'sf', -- Find surrounding (to the right)
511
+ find_left = 'sF', -- Find surrounding (to the left)
512
+ highlight = 'sh', -- Highlight surrounding
513
+ replace = 'sr', -- Replace surrounding
514
+
515
+ suffix_last = 'l', -- Suffix to search with "prev" method
516
+ suffix_next = 'n', -- Suffix to search with "next" method
517
+ },
518
+
519
+ -- Number of lines within which surrounding is searched
520
+ n_lines = 20,
521
+
522
+ -- Whether to respect selection type:
523
+ -- - Place surroundings on separate lines in linewise mode.
524
+ -- - Place surroundings on each line in blockwise mode.
525
+ respect_selection_type = false,
526
+
527
+ -- How to search for surrounding (first inside current line, then inside
528
+ -- neighborhood). One of 'cover', 'cover_or_next', 'cover_or_prev',
529
+ -- 'cover_or_nearest', 'next', 'prev', 'nearest'. For more details,
530
+ -- see `:h MiniSurround.config`.
531
+ search_method = 'cover',
532
+
533
+ -- Whether to disable showing non-error feedback
534
+ -- This also affects (purely informational) helper messages shown after
535
+ -- idle time if user input is required.
536
+ silent = false,
537
+ }
538
+ <
539
+ # Mappings ~
540
+
541
+ `config.mappings` defines what mappings are set up for particular actions.
542
+ By default it uses "prefix style" left hand side starting with "s" (for
543
+ "surround"): `sa` - "surround add", `sd` - "surround delete", etc.
544
+
545
+ Note: if any of the mappings start with "s" (as is by default), it is mapped
546
+ to |<Nop>| to prevent accidental trigger of built-in |s| (can happen if there
547
+ is a long enough delay between pressing "s" and the next key). Use `cl` instead.
548
+
549
+ # Custom surroundings ~
550
+
551
+ User can define own surroundings by supplying `config.custom_surroundings`.
552
+ It should be a table with keys being single character surrounding
553
+ identifier (supported by |getcharstr()|) and values - surround specification
554
+ (see |MiniSurround-surrounding-specification|).
555
+
556
+ General recommendations:
557
+ - In `config.custom_surroundings` only some data can be defined (like only
558
+ `output`). Other fields will be taken from builtin surroundings.
559
+ - Function returning surround info at <input> or <output> fields of
560
+ specification is helpful when user input is needed (like asking for
561
+ function name). Use |MiniSurround.user_input()| or |MiniInput.get()|.
562
+ Return `nil` to stop any current surround operation.
563
+ - Keys should use character representation which can be |getcharstr()| output.
564
+ For example, `'\r'` and not `'<CR>'`.
565
+
566
+ Examples of using `config.custom_surroundings` (see more examples at
567
+ |MiniSurround.gen_spec|): >lua
568
+
569
+ local surround = require('mini.surround')
570
+ surround.setup({
571
+ custom_surroundings = {
572
+ -- Make `)` insert parts with spaces. `input` pattern stays the same.
573
+ [')'] = { output = { left = '( ', right = ' )' } },
574
+
575
+ -- Use function to compute surrounding info
576
+ ['*'] = {
577
+ input = function()
578
+ local n_star = MiniSurround.user_input('Number of * to find')
579
+ local many_star = string.rep('%*', tonumber(n_star) or 1)
580
+ return { many_star .. '().-()' .. many_star }
581
+ end,
582
+ output = function()
583
+ local n_star = MiniSurround.user_input('Number of * to output')
584
+ local many_star = string.rep('*', tonumber(n_star) or 1)
585
+ return { left = many_star, right = many_star }
586
+ end,
587
+ },
588
+ },
589
+ })
590
+
591
+ -- Create custom surrounding for Lua's block string `[[...]]`
592
+ -- Use this inside autocommand or 'after/ftplugin/lua.lua' file
593
+ vim.b.minisurround_config = {
594
+ custom_surroundings = {
595
+ s = {
596
+ input = { '%[%[().-()%]%]' },
597
+ output = { left = '[[', right = ']]' },
598
+ },
599
+ },
600
+ }
601
+ <
602
+ # Respect selection type ~
603
+
604
+ Boolean option `config.respect_selection_type` controls whether to respect
605
+ selection type when adding and deleting surrounding. When enabled:
606
+ - Linewise adding places surroundings on separate lines while indenting
607
+ surrounded lines ones.
608
+ - Deleting surroundings which look like they were the result of linewise
609
+ adding will act to revert it: delete lines with surroundings and dedent
610
+ surrounded lines ones.
611
+ - Blockwise adding places surroundings on whole edges, not only start and
612
+ end of selection. Note: it doesn't really work outside of text and in
613
+ presence of multibyte characters; and probably won't due to
614
+ implementation difficulties.
615
+
616
+ # Search method ~
617
+
618
+ Value of `config.search_method` defines how best match search is done.
619
+ Based on its value, one of the following matches will be selected:
620
+ - Covering match. Left/right edge is before/after left/right edge of
621
+ reference region.
622
+ - Previous match. Left/right edge is before left/right edge of reference
623
+ region.
624
+ - Next match. Left/right edge is after left/right edge of reference region.
625
+ - Nearest match. Whichever is closest among previous and next matches.
626
+
627
+ Possible values are:
628
+ - `'cover'` (default) - use only covering match. Don't use either previous or
629
+ next; report that there is no surrounding found.
630
+ - `'cover_or_next'` - use covering match. If not found, use next.
631
+ - `'cover_or_prev'` - use covering match. If not found, use previous.
632
+ - `'cover_or_nearest'` - use covering match. If not found, use nearest.
633
+ - `'next'` - use next match.
634
+ - `'previous'` - use previous match.
635
+ - `'nearest'` - use nearest match.
636
+
637
+ Note: search is first performed on the reference region lines and only
638
+ after failure - on the whole neighborhood defined by `config.n_lines`. This
639
+ means that with `config.search_method` not equal to `'cover'`, "previous"
640
+ or "next" surrounding will end up as search result if they are found on
641
+ first stage although covering match might be found in bigger, whole
642
+ neighborhood. This design is based on observation that most of the time
643
+ operation is done within reference region lines (usually cursor line).
644
+
645
+ Here is an example of how replacing `)` with `]` surrounding is done based
646
+ on a value of `'config.search_method'` when cursor is inside `bbb` word:
647
+ - `'cover'`: `(a) bbb (c)` -> `(a) bbb (c)` (with message)
648
+ - `'cover_or_next'`: `(a) bbb (c)` -> `(a) bbb [c]`
649
+ - `'cover_or_prev'`: `(a) bbb (c)` -> `[a] bbb (c)`
650
+ - `'cover_or_nearest'`: depends on cursor position.
651
+ For first and second `b` - as in `cover_or_prev` (as previous match is
652
+ nearer), for third - as in `cover_or_next` (as next match is nearer).
653
+ - `'next'`: `(a) bbb (c)` -> `(a) bbb [c]`. Same outcome for `(bbb)`.
654
+ - `'prev'`: `(a) bbb (c)` -> `[a] bbb (c)`. Same outcome for `(bbb)`.
655
+ - `'nearest'`: depends on cursor position (same as in `'cover_or_nearest'`).
656
+
657
+ # Search suffixes ~
658
+
659
+ To provide more searching possibilities, |mini.surround| creates extended
660
+ mappings force "prev" and "next" methods for particular search. It does so
661
+ by appending mapping with certain suffix: `config.mappings.suffix_last` for
662
+ mappings which will use "prev" search method, `config.mappings.suffix_next`
663
+ - "next" search method.
664
+
665
+ Notes:
666
+ - It creates new mappings only for actions involving surrounding search:
667
+ delete, replace, find (right and left), highlight.
668
+ - All new mappings behave the same way as if `config.search_method` is set
669
+ to certain search method. They preserve dot-repeat support, respect |[count]|.
670
+ - Supply empty string to disable creation of corresponding set of mappings.
671
+
672
+ Example with default values (`n` for `suffix_next`, `l` for `suffix_last`)
673
+ and initial line `(aa) (bb) (cc)`.
674
+ - Typing `sdn)` with cursor inside `(aa)` results into `(aa) bb (cc)`.
675
+ - Typing `sdl)` with cursor inside `(cc)` results into `(aa) bb (cc)`.
676
+ - Typing `2srn)]` with cursor inside `(aa)` results into `(aa) (bb) [cc]`.
677
+
678
+ # Setup similar to `tpope/vim-surround` ~
679
+ *MiniSurround-vim-surround-config*
680
+
681
+ This module is primarily designed after `machakann/vim-sandwich`. To get
682
+ behavior closest to `tpope/vim-surround` (but not identical), use this setup: >lua
683
+
684
+ require('mini.surround').setup({
685
+ mappings = {
686
+ add = 'ys',
687
+ delete = 'ds',
688
+ find = '',
689
+ find_left = '',
690
+ highlight = '',
691
+ replace = 'cs',
692
+
693
+ -- Add this only if you don't want to use extended mappings
694
+ suffix_last = '',
695
+ suffix_next = '',
696
+ },
697
+ search_method = 'cover_or_next',
698
+ })
699
+
700
+ -- Remap adding surrounding to Visual mode selection
701
+ vim.keymap.del('x', 'ys')
702
+ vim.keymap.set('x', 'S', [[:<C-u>lua MiniSurround.add('visual')<CR>]], { silent = true })
703
+
704
+ -- Make special mapping for "add surrounding for line"
705
+ vim.keymap.set('n', 'yss', 'ys_', { remap = true })
706
+ <
707
+ ------------------------------------------------------------------------------
708
+ *MiniSurround.add()*
709
+ `MiniSurround.add`({mode})
710
+ Add surrounding
711
+
712
+ No need to use it directly, everything is setup in |MiniSurround.setup()|.
713
+
714
+ Parameters ~
715
+ {mode} `(string)` Mapping mode (normal by default).
716
+
717
+ ------------------------------------------------------------------------------
718
+ *MiniSurround.delete()*
719
+ `MiniSurround.delete`()
720
+ Delete surrounding
721
+
722
+ No need to use it directly, everything is setup in |MiniSurround.setup()|.
723
+
724
+ ------------------------------------------------------------------------------
725
+ *MiniSurround.replace()*
726
+ `MiniSurround.replace`()
727
+ Replace surrounding
728
+
729
+ No need to use it directly, everything is setup in |MiniSurround.setup()|.
730
+
731
+ ------------------------------------------------------------------------------
732
+ *MiniSurround.find()*
733
+ `MiniSurround.find`()
734
+ Find surrounding
735
+
736
+ No need to use it directly, everything is setup in |MiniSurround.setup()|.
737
+
738
+ ------------------------------------------------------------------------------
739
+ *MiniSurround.highlight()*
740
+ `MiniSurround.highlight`()
741
+ Highlight surrounding
742
+
743
+ No need to use it directly, everything is setup in |MiniSurround.setup()|.
744
+
745
+ ------------------------------------------------------------------------------
746
+ *MiniSurround.update_n_lines()*
747
+ `MiniSurround.update_n_lines`()
748
+ Update `MiniSurround.config.n_lines` from user input
749
+
750
+ Mapping example: >lua
751
+
752
+ vim.keymap.set('n', 'sn', '<Cmd>lua MiniSurround.update_n_lines()<CR>')
753
+ <
754
+ ------------------------------------------------------------------------------
755
+ *MiniSurround.user_input()*
756
+ `MiniSurround.user_input`({prompt}, {text})
757
+ Ask user for input
758
+
759
+ This is mainly a wrapper for |input()| which allows empty string as input,
760
+ cancelling with `<Esc>` and `<C-c>`, and slightly modifies prompt. Use it
761
+ to ask for input inside function custom surrounding (see |MiniSurround.config|).
762
+
763
+ ------------------------------------------------------------------------------
764
+ *MiniSurround.gen_spec*
765
+ `MiniSurround.gen_spec`
766
+ Generate common surrounding specifications
767
+
768
+ This is a table with two sets of generator functions: <input> and <output>
769
+ (currently empty). Each is a table with function values generating
770
+ corresponding surrounding specification.
771
+
772
+ See also ~
773
+ |MiniAi.gen_spec|
774
+
775
+ ------------------------------------------------------------------------------
776
+ *MiniSurround.gen_spec.input.treesitter()*
777
+ `MiniSurround.gen_spec.input.treesitter`({captures}, {opts})
778
+ Treesitter specification for input surrounding
779
+
780
+ This is a specification in function form. When called with a pair of
781
+ treesitter captures, it returns a specification function outputting an
782
+ array of region pairs derived from <outer> and <inner> captures. It first
783
+ searches for all matched nodes of outer capture and then completes each one
784
+ with the biggest match of inner capture inside that node (if any). The result
785
+ region pair is a difference between regions of outer and inner captures.
786
+
787
+ In order for this to work, apart from working treesitter parser for desired
788
+ language, user should have a reachable language-specific `'textobjects'`
789
+ query (see |vim.treesitter.query.get()|).
790
+ The most straightforward way for this is to have `textobjects.scm` query
791
+ file with treesitter captures stored in some recognized path. This is
792
+ primarily designed to be compatible with plugin
793
+ `nvim-treesitter/nvim-treesitter-textobjects`, but can be used without it.
794
+
795
+ Two most common approaches for having a query file:
796
+ - Install `nvim-treesitter/nvim-treesitter-textobjects`. It has curated and
797
+ well maintained builtin query files for many languages with a standardized
798
+ capture names, like `call.outer`, `call.inner`, etc.
799
+ - Manually create file `after/queries/<language-name>/textobjects.scm` in
800
+ your |$XDG_CONFIG_HOME| directory. It should contain queries with
801
+ captures (later used to define surrounding parts). See |lua-treesitter-query|.
802
+ To verify that query file is reachable, run (example for "lua" language,
803
+ output should have at least an intended file): >vim
804
+
805
+ :lua print(vim.inspect(vim.treesitter.query.get_files('lua','textobjects')))
806
+ <
807
+ Example configuration for function definition textobject with
808
+ `nvim-treesitter/nvim-treesitter-textobjects` captures: >lua
809
+
810
+ local ts_input = require('mini.surround').gen_spec.input.treesitter
811
+ require('mini.surround').setup({
812
+ custom_surroundings = {
813
+ -- Use tree-sitter to search for function call
814
+ f = {
815
+ input = ts_input({ outer = '@call.outer', inner = '@call.inner' })
816
+ },
817
+ }
818
+ })
819
+ <
820
+ Notes:
821
+ - Be sure that query files don't contain unknown |treesitter-directives|
822
+ (like `#make-range!`, for example). Otherwise surrounding with such captures
823
+ might not be found as |lua-treesitter-core| won't treat them as captures.
824
+ Verify with `:=vim.treesitter.query.get('lang', 'textobjects')` and see
825
+ if the target capture is recognized as one.
826
+ - It uses buffer's |filetype| to determine query language.
827
+ - It first searches the language under cursor for matches. If no matches are
828
+ found, it falls back to searching parent languages (up to the buffer's root
829
+ language). If no matches are found again, it falls back to recursively
830
+ searching all children languages (from the language under cursor). If no
831
+ matches again - report no matches.
832
+ - On large files it is slower than pattern-based textobjects. Still very
833
+ fast though (one search should be magnitude of milliseconds or tens of
834
+ milliseconds on really large file).
835
+
836
+ Parameters ~
837
+ {captures} `(table)` Captures for outer and inner parts of region pair:
838
+ table with <outer> and <inner> fields with captures for outer
839
+ (`[left.form; right.to]`) and inner (`(left.to; right.from)` both edges
840
+ exclusive, i.e. they won't be a part of surrounding) regions. Each value
841
+ should be a string capture starting with `'@'`.
842
+ {opts} `(table|nil)` Options. Possible values:
843
+ - <use_nvim_treesitter> - whether to try to use `nvim-treesitter` plugin
844
+ (if present) to do the query. It used to implement more advanced behavior
845
+ and more coherent experience if `nvim-treesitter-textobjects` queries are
846
+ used. However, as |lua-treesitter-core| methods are more capable now,
847
+ the option will soon be removed. Only present for backward compatibility.
848
+ Default: `false`.
849
+
850
+ Return ~
851
+ `(function)` Function which returns array of current buffer region pairs
852
+ representing differences between outer and inner captures.
853
+
854
+ See also ~
855
+ - |MiniSurround-surrounding-specification| for how this type of
856
+ surrounding specification is processed.
857
+ - |vim.treesitter.query.get()| for how query is fetched.
858
+ - |Query:iter_captures()| for how all query captures are iterated in case of
859
+ no `nvim-treesitter`.
860
+ - |MiniAi.gen_spec.treesitter()| for similar |mini.ai| generator.
861
+
862
+
863
+ vim:tw=78:ts=8:noet:ft=help:norl: