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,937 @@
1
+ *mini.visits* Track and reuse file system visits
2
+
3
+ MIT License Copyright (c) 2023 Evgeni Chasnovski
4
+
5
+ ------------------------------------------------------------------------------
6
+ *MiniVisits*
7
+ Features:
8
+
9
+ - Persistently track file system visits (both files and directories)
10
+ per project directory. Store visit index is human readable and editable.
11
+
12
+ - Visit index is normalized on every write to contain relevant information.
13
+ Exact details can be customized. See |MiniVisits.normalize_index()|.
14
+
15
+ - Built-in ability to persistently add labels to path for later use.
16
+ See |MiniVisits.add_label()| and |MiniVisits.remove_label()|.
17
+
18
+ - Exported functions to reuse visit data:
19
+ - List visited paths/labels with custom filter and sort (uses "robust
20
+ frecency" by default). Can be used as source for pickers.
21
+ See |MiniVisits.list_paths()| and |MiniVisits.list_labels()|.
22
+ See |MiniVisits.gen_filter| and |MiniVisits.gen_sort|.
23
+
24
+ - Select visited paths/labels using |vim.ui.select()|.
25
+ See |MiniVisits.select_path()| and |MiniVisits.select_label()|.
26
+
27
+ - Iterate through visit paths in target direction ("forward", "backward",
28
+ "first", "last"). See |MiniVisits.iterate_paths()|.
29
+
30
+ - Exported functions to manually update visit index allowing persistent
31
+ track of any user information. See `*_index()` functions.
32
+
33
+ Notes:
34
+ - All data is stored _only_ in in-session Lua variable (for quick operation)
35
+ and at `config.store.path` on disk (for persistent usage).
36
+ - Most of functions affect an in-session data which gets written to disk only
37
+ before Neovim is closing or when users asks to.
38
+ - It doesn't account for paths being renamed or moved (because there is no
39
+ general way to detect that). Usually a manual intervention to the visit
40
+ index is required after the change but _before_ the next writing to disk
41
+ (usually before closing current session) because it will treat previous
42
+ path as deleted and remove it from index.
43
+ There is a |MiniVisits.rename_in_index()| helper for that.
44
+ If rename/move is done with |mini.files|, index is autoupdated.
45
+
46
+ Sources with more details:
47
+ - |MiniVisits-overview|
48
+ - |MiniVisits-index-specification|
49
+ - |MiniVisits-examples|
50
+
51
+ # Setup ~
52
+
53
+ This module needs a setup with `require('mini.visits').setup({})` (replace
54
+ `{}` with your `config` table). It will create global Lua table `MiniVisits`
55
+ which you can use for scripting or manually (with `:lua MiniVisits.*`).
56
+
57
+ See |MiniVisits.config| for `config` structure and default values.
58
+
59
+ You can override runtime config settings locally to buffer inside
60
+ `vim.b.minivisits_config` which should have same structure as
61
+ `MiniVisits.config`. See |mini.nvim-buffer-local-config| for more details.
62
+
63
+ # Comparisons ~
64
+
65
+ - [nvim-telescope/telescope-frecency.nvim](https://github.com/nvim-telescope/telescope-frecency.nvim):
66
+ - It stores array of actual visit timestamps, while this module tracks
67
+ only total number and latest timestamp of visits. This is by design
68
+ as a different trade-off between how much data is being used/stored
69
+ and complexity of underlying "frecency" sorting.
70
+ - By default tracks a buffer only once per session, while this module
71
+ tracks on every meaningful buffer enter. This leads to a more relevant
72
+ in-session sorting.
73
+ - Implements an original frecency algorithm of Firefox's address bar,
74
+ while this module uses own "robust frecency" approach.
75
+ - Mostly designed to work with `nvim-telescope/telescope.nvim`, while
76
+ this module provides general function to list paths and select
77
+ with |vim.ui.select()|.
78
+ - Does not allow use of custom data (like labels), while this module does.
79
+
80
+ - [ThePrimeagen/harpoon](https://github.com/ThePrimeagen/harpoon):
81
+ - Has slightly different concept than general labeling, which more
82
+ resembles adding paths to an ordered stack. This module implements
83
+ a more common labeling which does not imply order with ability to
84
+ make it automated depending on the task and/or preference.
85
+ - Implements marks as positions in a path, while this module labels paths.
86
+ - Writes data on disk after every meaning change, while this module is
87
+ more conservative and read only when Neovim closes or when asked to.
88
+ - Has support for labeling terminals, while this modules is oriented
89
+ only towards paths.
90
+ - Has dedicated UI to manage marks, while this module does not by design.
91
+ There are functions for adding and removing label from the path.
92
+ - Does not provide functionality to track and reuse any visited path,
93
+ while this module does.
94
+
95
+ # Disabling ~
96
+
97
+ To disable automated tracking, set `vim.g.minivisits_disable` (globally) or
98
+ `vim.b.minivisits_disable` (for a buffer) to `true`. Considering high
99
+ number of different scenarios and customization intentions, writing exact
100
+ rules for disabling module's functionality is left to user. See
101
+ |mini.nvim-disabling-recipes| for common recipes.
102
+
103
+ ------------------------------------------------------------------------------
104
+ *MiniVisits-overview*
105
+ # Tracking visits ~
106
+
107
+ File system visits (both directory and files) tracking is done in two steps:
108
+ - On every dedicated event (`config.track.event`, |BufEnter| by default) timer
109
+ is (re)started to actually register visit after certain amount of time
110
+ (`config.track.delay` milliseconds, 1000 by default). It is not registered
111
+ immediately to allow navigation to target buffer in several steps
112
+ (for example, with series of |:bnext| / |:bprevious|).
113
+
114
+ - When delay time passes without any dedicated events being triggered
115
+ (meaning user is "settled" on certain buffer), |MiniVisits.register_visit()|
116
+ is called if all of the following conditions are met:
117
+ - Module is not disabled (see "Disabling" section in |mini.visits|).
118
+ - Buffer is normal with non-empty name (used as visit path).
119
+ - Visit path does not equal to the latest tracked one. This is to allow
120
+ temporary enter of non-normal buffers (like help, terminal, etc.)
121
+ without artificial increase of visit count.
122
+
123
+ Visit is autoregistered for |current-directory| and leads to increase of count
124
+ and latest time of visit. See |MiniVisits-index-specification| for more details.
125
+
126
+ Notes:
127
+ - All data is stored _only_ in in-session Lua variable (for quick operation)
128
+ and at `config.store.path` on disk (for persistent usage). It is automatically
129
+ written to disk before every Neovim exit (if `config.store.autowrite` is set).
130
+
131
+ - Tracking can be disabled by supplying empty string as `track.event`.
132
+ Then it is up to the user to properly call |MiniVisits.register_visit()|.
133
+
134
+ # Reusing visits ~
135
+
136
+ Visit data can be reused in at least these ways:
137
+
138
+ - Get a list of visited paths (see |MiniVisits.list_paths()|) and use it
139
+ to visualize/pick/navigate visit history.
140
+
141
+ - Select one of the visited paths to open it (see |MiniVisits.select_path()|).
142
+
143
+ - Move along visit history (see |MiniVisits.iterate_paths()|).
144
+
145
+ - Utilize labels. Any visit can be added one or more labels (like "core",
146
+ "tmp", etc.). They are bound to the visit (path registered for certain
147
+ directory) and are stored persistently.
148
+ Labels can be used to manually create groups of files and/or directories
149
+ that have particular interest to the user.
150
+ There is no one right way to use them, though. See |MiniVisits-examples|
151
+ for some inspiration.
152
+
153
+ - Utilizing custom data. Visit index can be manipulated manually using
154
+ `_index()` set of functions. All "storable" (i.e. not functions or
155
+ metatables) user data inside index is then stored on disk, so it can be
156
+ used to create any kind of workflow user wants.
157
+
158
+ See |MiniVisits-examples| for some actual configuration and workflow examples.
159
+
160
+ ------------------------------------------------------------------------------
161
+ *MiniVisits-index-specification*
162
+ # Structure ~
163
+
164
+ Visit index is a table containing actual data in two level deep nested tables.
165
+
166
+ First level keys are paths of project directory (a.k.a "cwd") for which
167
+ visits are registered.
168
+
169
+ Second level keys are actual visit paths. Their values are tables with visit
170
+ data which should follow these requirements:
171
+ - Field <count> should be present and be a number. It represents the number
172
+ of times this path was visited under particular cwd.
173
+ - Field <latest> should be present and be a number. It represents the time
174
+ of latest path visit under particular cwd.
175
+ By default computed with |os.time()| (up to a second).
176
+ - Field <labels> might not be present. If present, it should be a table
177
+ with string labels as keys and `true` as values. It represents labels of
178
+ the path under particular cwd.
179
+
180
+ Notes:
181
+ - All paths are absolute.
182
+ - Visit path should not necessarily be a part of corresponding cwd.
183
+ - Both `count` and `latest` can be any number: whole, fractional, negative, etc.
184
+
185
+ Example of an index data: >lua
186
+
187
+ {
188
+ ['/home/user/project_1'] = {
189
+ ['home/user/project_1/file'] = { count = 3, latest = 1699796000 },
190
+ ['home/user/project_1/subdir'] = {
191
+ count = 10, latest = 1699797000, labels = { core = true },
192
+ },
193
+ },
194
+ ['/home/user/project_2'] = {
195
+ ['home/user/project_1/file'] = {
196
+ count = 0, latest = 0, labels = { other = true },
197
+ },
198
+ ['home/user/project_2/README'] = { count = 1, latest = 1699798000 },
199
+ },
200
+ }
201
+ <
202
+ # Storage ~
203
+
204
+ When stored on disk, visit index is a file containing Lua code returning
205
+ visit index table. It can be edited by hand as long as it contains a valid
206
+ Lua code (to be executed with |dofile()|).
207
+
208
+ Notes:
209
+ - Storage is implemented in such a way that it doesn't really support more
210
+ than one parallel Neovim processes. Meaning that if there are two or more
211
+ simultaneous Neovim processes with same visit index storage path, the last
212
+ one writing to it will preserve its visit history while others - won't.
213
+
214
+ # Normalization ~
215
+
216
+ To ensure that visit index contains mostly relevant data, it gets normalized:
217
+ automatically inside |MiniVisits.write_index()| or
218
+ via |MiniVisits.normalize_index()|.
219
+
220
+ What normalization actually does can be configured in `config.store.normalize`.
221
+
222
+ See |MiniVisits.gen_normalize.default()| for default normalization approach.
223
+
224
+ ------------------------------------------------------------------------------
225
+ *MiniVisits-examples*
226
+ This module provides a flexible framework for working with file system visits.
227
+ Exact choice of how to organize workflow is left to the user.
228
+ Here are some examples for inspiration which can be combined together.
229
+
230
+ # Use different sorting ~
231
+
232
+ Default sorting in |MiniVisits.gen_sort.default()| allows flexible adjustment
233
+ of which feature to prefer more: recency or frequency. Here is an example of
234
+ how to make set of keymaps for three types of sorting combined with two types
235
+ of scopes (all visits and only for current cwd): >lua
236
+
237
+ local make_select_path = function(select_global, recency_weight)
238
+ local visits = require('mini.visits')
239
+ local sort = visits.gen_sort.default({ recency_weight = recency_weight })
240
+ local select_opts = { sort = sort }
241
+ return function()
242
+ local cwd = select_global and '' or vim.fn.getcwd()
243
+ visits.select_path(cwd, select_opts)
244
+ end
245
+ end
246
+
247
+ local map = function(lhs, desc, ...)
248
+ vim.keymap.set('n', lhs, make_select_path(...), { desc = desc })
249
+ end
250
+
251
+ -- Adjust LHS and description to your liking
252
+ map('<Leader>vr', 'Select recent (all)', true, 1)
253
+ map('<Leader>vR', 'Select recent (cwd)', false, 1)
254
+ map('<Leader>vy', 'Select frecent (all)', true, 0.5)
255
+ map('<Leader>vY', 'Select frecent (cwd)', false, 0.5)
256
+ map('<Leader>vf', 'Select frequent (all)', true, 0)
257
+ map('<Leader>vF', 'Select frequent (cwd)', false, 0)
258
+ <
259
+ Note: If using |mini.pick|, consider |MiniExtra.pickers.visit_paths()|.
260
+
261
+ # Use manual labels ~
262
+
263
+ Labels is a powerful tool to create groups of associated paths.
264
+ Usual workflow consists of:
265
+ - Add label with |MiniVisits.add_label()| (prompts for actual label).
266
+ - Remove label with |MiniVisits.remove_label()| (prompts for actual label).
267
+ - When need to use labeled groups, call |MiniVisits.select_label()| which
268
+ will then call |MiniVisits.select_path()| to select path among those
269
+ having selected label.
270
+ Note: If using |mini.pick|, consider |MiniExtra.pickers.visit_labels()|.
271
+
272
+ To make this workflow smoother, here is an example of keymaps: >lua
273
+
274
+ local map_vis = function(keys, call, desc)
275
+ local rhs = '<Cmd>lua MiniVisits.' .. call .. '<CR>'
276
+ vim.keymap.set('n', '<Leader>' .. keys, rhs, { desc = desc })
277
+ end
278
+
279
+ map_vis('vv', 'add_label()', 'Add label')
280
+ map_vis('vV', 'remove_label()', 'Remove label')
281
+ map_vis('vl', 'select_label("", "")', 'Select label (all)')
282
+ map_vis('vL', 'select_label()', 'Select label (cwd)')
283
+ <
284
+ # Use fixed labels ~
285
+
286
+ During work on every project there is usually a handful of files where core
287
+ activity is concentrated. This can be made easier by creating mappings
288
+ which add/remove special fixed label (for example, "core") and select paths
289
+ with that label for both all and current cwd. Example: >lua
290
+
291
+ -- Create and select
292
+ local map_vis = function(keys, call, desc)
293
+ local rhs = '<Cmd>lua MiniVisits.' .. call .. '<CR>'
294
+ vim.keymap.set('n', '<Leader>' .. keys, rhs, { desc = desc })
295
+ end
296
+
297
+ map_vis('vv', 'add_label("core")', 'Add to core')
298
+ map_vis('vV', 'remove_label("core")', 'Remove from core')
299
+ map_vis('vc', 'select_path("", { filter = "core" })', 'Select core (all)')
300
+ map_vis('vC', 'select_path(nil, { filter = "core" })', 'Select core (cwd)')
301
+
302
+ -- Iterate based on recency
303
+ local sort_latest = MiniVisits.gen_sort.default({ recency_weight = 1 })
304
+ local map_iterate_core = function(lhs, direction, desc)
305
+ local opts = { filter = 'core', sort = sort_latest, wrap = true }
306
+ local rhs = function()
307
+ MiniVisits.iterate_paths(direction, vim.fn.getcwd(), opts)
308
+ end
309
+ vim.keymap.set('n', lhs, rhs, { desc = desc })
310
+ end
311
+
312
+ map_iterate_core('[{', 'last', 'Core label (earliest)')
313
+ map_iterate_core('[[', 'forward', 'Core label (earlier)')
314
+ map_iterate_core(']]', 'backward', 'Core label (later)')
315
+ map_iterate_core(']}', 'first', 'Core label (latest)')
316
+ <
317
+ # Use automated labels ~
318
+
319
+ When using version control system (such as Git), usually there is already
320
+ an identifier that groups files you are working with - branch name.
321
+ Here is an example of keymaps to add/remove label equal to branch name: >lua
322
+
323
+ local map_branch = function(keys, action, desc)
324
+ local rhs = function()
325
+ local branch = vim.fn.system('git rev-parse --abbrev-ref HEAD')
326
+ if vim.v.shell_error ~= 0 then return nil end
327
+ branch = vim.trim(branch)
328
+ require('mini.visits')[action](branch)
329
+ end
330
+ vim.keymap.set('n', '<Leader>' .. keys, rhs, { desc = desc })
331
+ end
332
+
333
+ map_branch('vb', 'add_label', 'Add branch label')
334
+ map_branch('vB', 'remove_label', 'Remove branch label')
335
+ <
336
+ ------------------------------------------------------------------------------
337
+ *MiniVisits.setup()*
338
+ `MiniVisits.setup`({config})
339
+ Module setup
340
+
341
+ Parameters ~
342
+ {config} `(table|nil)` Module config table. See |MiniVisits.config|.
343
+
344
+ Usage ~
345
+ >lua
346
+ require('mini.visits').setup() -- use default config
347
+ -- OR
348
+ require('mini.visits').setup({}) -- replace {} with your config table
349
+ <
350
+ ------------------------------------------------------------------------------
351
+ *MiniVisits.config*
352
+ `MiniVisits.config`
353
+ Defaults ~
354
+ >lua
355
+ MiniVisits.config = {
356
+ -- How visit index is converted to list of paths
357
+ list = {
358
+ -- Predicate for which paths to include (all by default)
359
+ filter = nil,
360
+
361
+ -- Sort paths based on the visit data (robust frecency by default)
362
+ sort = nil,
363
+ },
364
+
365
+ -- Whether to disable showing non-error feedback
366
+ silent = false,
367
+
368
+ -- How visit index is stored
369
+ store = {
370
+ -- Whether to write all visits before Neovim is closed
371
+ autowrite = true,
372
+
373
+ -- Function to ensure that written index is relevant
374
+ normalize = nil,
375
+
376
+ -- Path to store visit index
377
+ path = vim.fn.stdpath('data') .. '/mini-visits-index',
378
+ },
379
+
380
+ -- How visit tracking is done
381
+ track = {
382
+ -- Start visit register timer at this event
383
+ -- Supply empty string (`''`) to not do this automatically
384
+ event = 'BufEnter',
385
+
386
+ -- Debounce delay after event to register a visit
387
+ delay = 1000,
388
+ },
389
+ }
390
+ <
391
+ # List ~
392
+ *MiniVisits.config.list*
393
+
394
+ `config.list` defines how visit index is converted to a path list by default.
395
+
396
+ `list.filter` is a callable which should take a path data and return `true` if
397
+ this path should be present in the list.
398
+ Default: output of |MiniVisits.gen_filter.default()|.
399
+
400
+ Path data is a table with at least these fields:
401
+ - <path> `(string)` - absolute path of visit.
402
+ - <count> `(number)` - number of visits.
403
+ - <latest> `(number)` - timestamp of latest visit.
404
+ - <labels> `(table|nil)` - table of labels (has string keys with `true` values).
405
+
406
+ Notes:
407
+ - Both `count` and `latest` (in theory) can be any number. But built-in tracking
408
+ results into positive integer `count` and `latest` coming from |os.time()|.
409
+ - There can be other entries if they are set by user as index entry.
410
+
411
+ `list.sort` is a callable which should take an array of path data and return
412
+ a sorted array of path data (or at least tables each containing <path> field).
413
+ Default: output of |MiniVisits.gen_sort.default()|.
414
+ Single path data entry is a table with a same structure as for `list.filter`.
415
+
416
+ Note, that `list.sort` can be used both to filter, sort, or even return paths
417
+ unrelated to the input.
418
+
419
+ # Silent ~
420
+
421
+ `config.silent` is a boolean controlling whether to show non-error feedback
422
+ (like adding/removing labels, etc.). Default: `false`.
423
+
424
+ # Store ~
425
+
426
+ `config.store` defines how visit index is stored on disk to enable persistent
427
+ data across several sessions.
428
+
429
+ `store.autowrite` is a boolean controlling whether to write visit data to
430
+ disk on |VimLeavePre| event. Default: `true`.
431
+
432
+ `store.normalize` is a callable which should take visit index
433
+ (see |MiniVisits-index-specification|) as input and return "normalized" visit
434
+ index as output. This is used to ensure that visit index is up to date and
435
+ contains only relevant data. For example, it controls how old and
436
+ irrelevant visits are "forgotten", and more.
437
+ Default: output of |MiniVisits.gen_normalize.default()|.
438
+
439
+ `store.path` is a path to which visit index is written. See "Storage" section
440
+ of |MiniVisits-index-specification| for more details.
441
+ Note: set to empty string to disable any writing with not explicitly set
442
+ path (including the one on |VimLeavePre|).
443
+ Default: "mini-visits-index" file inside |$XDG_DATA_HOME|.
444
+
445
+ # Track ~
446
+
447
+ `config.track` defines how visits are tracked (index entry is autoupdated).
448
+ See "Tracking visits" section in |MiniVisits-overview| for more details.
449
+
450
+ `track.event` is a proper Neovim |{event}| on which track get triggered.
451
+ Note: set to empty string to disable automated tracking.
452
+ Default: |BufEnter|.
453
+
454
+ `track.delay` is a delay in milliseconds after event is triggered and visit
455
+ is autoregistered.
456
+ Default: 1000 (to allow navigation between buffers without tracking
457
+ intermediate ones).
458
+
459
+ ------------------------------------------------------------------------------
460
+ *MiniVisits.register_visit()*
461
+ `MiniVisits.register_visit`({path}, {cwd})
462
+ Register visit
463
+
464
+ Steps:
465
+ - Ensure that there is an entry for path-cwd pair.
466
+ - Add 1 to visit `count`.
467
+ - Set `latest` visit time to equal current time.
468
+
469
+ Parameters ~
470
+ {path} `(string|nil)` Visit path. Default: path of current buffer if normal,
471
+ error otherwise.
472
+ {cwd} `(string|nil)` Visit cwd (project directory). Default: |current-directory|.
473
+
474
+ ------------------------------------------------------------------------------
475
+ *MiniVisits.add_path()*
476
+ `MiniVisits.add_path`({path}, {cwd})
477
+ Add path to index
478
+
479
+ Ensures that there is a (one or more) entry for path-cwd pair. If entry is
480
+ already present, does nothing. If not - creates it with both `count` and
481
+ `latest` set to 0.
482
+
483
+ Parameters ~
484
+ {path} `(string|nil)` Visit path. Can be empty string to mean "all visited
485
+ paths for `cwd`". Default: path of current buffer if normal, error otherwise.
486
+ {cwd} `(string|nil)` Visit cwd (project directory). Can be empty string to mean
487
+ "all visited cwd". Default: |current-directory|.
488
+
489
+ ------------------------------------------------------------------------------
490
+ *MiniVisits.add_label()*
491
+ `MiniVisits.add_label`({label}, {path}, {cwd})
492
+ Add label to path
493
+
494
+ Steps:
495
+ - Ensure that there is an entry for path-cwd pair.
496
+ - Add label to the entry.
497
+
498
+ Parameters ~
499
+ {label} `(string|nil)` Label string. Default: `nil` to ask with |vim.ui.input()|.
500
+ {path} `(string|nil)` Visit path. Can be empty string to mean "all visited
501
+ paths for `cwd`". Default: path of current buffer if normal, error otherwise.
502
+ {cwd} `(string|nil)` Visit cwd (project directory). Can be empty string to mean
503
+ "all visited cwd". Default: |current-directory|.
504
+
505
+ ------------------------------------------------------------------------------
506
+ *MiniVisits.remove_path()*
507
+ `MiniVisits.remove_path`({path}, {cwd})
508
+ Remove path
509
+
510
+ Deletes a (one or more) entry for path-cwd pair from an index. If entry is
511
+ already absent, does nothing.
512
+
513
+ Notes:
514
+ - Affects only in-session Lua variable. Call |MiniVisits.write_index()| to
515
+ make it persistent.
516
+
517
+ Parameters ~
518
+ {path} `(string|nil)` Visit path. Can be empty string to mean "all visited
519
+ paths for `cwd`". Default: path of current buffer if normal, error otherwise.
520
+ {cwd} `(string|nil)` Visit cwd (project directory). Can be empty string to mean
521
+ "all visited cwd". Default: |current-directory|.
522
+
523
+ ------------------------------------------------------------------------------
524
+ *MiniVisits.remove_label()*
525
+ `MiniVisits.remove_label`({label}, {path}, {cwd})
526
+ Remove label from path
527
+
528
+ Steps:
529
+ - Remove label from (one or more) index entry.
530
+ - If it was last label in an entry, remove `labels` key.
531
+
532
+ Parameters ~
533
+ {label} `(string|nil)` Label string. Default: `nil` to ask with |vim.ui.input()|.
534
+ {path} `(string|nil)` Visit path. Can be empty string to mean "all visited
535
+ paths for `cwd`". Default: path of current buffer if normal, error otherwise.
536
+ {cwd} `(string|nil)` Visit cwd (project directory). Can be empty string to mean
537
+ "all visited cwd". Default: |current-directory|.
538
+
539
+ ------------------------------------------------------------------------------
540
+ *MiniVisits.list_paths()*
541
+ `MiniVisits.list_paths`({cwd}, {opts})
542
+ List visit paths
543
+
544
+ Convert visit index for certain cwd into an ordered list of visited paths.
545
+ Supports custom filtering and sorting.
546
+
547
+ Examples: >lua
548
+
549
+ -- Get paths sorted from most to least recent
550
+ local sort_recent = MiniVisits.gen_sort.default({ recency_weight = 1 })
551
+ MiniVisits.list_paths(nil, { sort = sort_recent })
552
+
553
+ -- Get paths from all cwd sorted from most to least frequent
554
+ local sort_frequent = MiniVisits.gen_sort.default({ recency_weight = 0 })
555
+ MiniVisits.list_paths('', { sort = sort_frequent })
556
+
557
+ -- Get paths not including hidden
558
+ local is_not_hidden = function(path_data)
559
+ return not vim.startswith(vim.fn.fnamemodify(path_data.path, ':t'), '.')
560
+ end
561
+ MiniVisits.list_paths(nil, { filter = is_not_hidden })
562
+ <
563
+ Parameters ~
564
+ {cwd} `(string|nil)` Visit cwd (project directory). Can be empty string to mean
565
+ "all visited cwd". Default: |current-directory|.
566
+ {opts} `(table|nil)` Options. Possible fields:
567
+ - <filter> `(function)` - predicate to filter paths. For more information
568
+ about how it is used, see |MiniVisits.config.list|.
569
+ Default: value of `config.list.filter` with |MiniVisits.gen_filter.default()|
570
+ as its default.
571
+ - <sort> `(function)` - path data sorter. For more information about how
572
+ it is used, see |MiniVisits.config.list|.
573
+ Default: value of `config.list.sort` or |MiniVisits.gen_sort.default()|
574
+ as its default.
575
+
576
+ Return ~
577
+ `(table)` Array of visited paths.
578
+
579
+ ------------------------------------------------------------------------------
580
+ *MiniVisits.list_labels()*
581
+ `MiniVisits.list_labels`({path}, {cwd}, {opts})
582
+ List visit labels
583
+
584
+ Convert visit index for certain path-cwd pair into an ordered list of labels.
585
+ Supports custom filtering for paths. Result is ordered from most to least
586
+ frequent label.
587
+
588
+ Examples: >lua
589
+
590
+ -- Get labels for current path-cwd pair
591
+ MiniVisits.list_labels()
592
+
593
+ -- Get labels for current path across all cwd
594
+ MiniVisits.list_labels(nil, '')
595
+
596
+ -- Get all available labels excluding ones from hidden files
597
+ local is_not_hidden = function(path_data)
598
+ return not vim.startswith(vim.fn.fnamemodify(path_data.path, ':t'), '.')
599
+ end
600
+ MiniVisits.list_labels('', '', { filter = is_not_hidden })
601
+ <
602
+ Parameters ~
603
+ {path} `(string|nil)` Visit path. Can be empty string to mean "all visited
604
+ paths for `cwd`". Default: path of current buffer if normal, error otherwise.
605
+ {cwd} `(string|nil)` Visit cwd (project directory). Can be empty string to mean
606
+ "all visited cwd". Default: |current-directory|.
607
+ {opts} `(table|nil)` Options. Possible fields:
608
+ - <filter> `(function)` - predicate to filter paths. For more information
609
+ about how it is used, see |MiniVisits.config.list|.
610
+ Default: value of `config.list.filter` with |MiniVisits.gen_filter.default()|
611
+ as its default.
612
+ - <sort> `(function)` - path data sorter. For more information about how
613
+ it is used, see |MiniVisits.config.list|.
614
+ Default: value of `config.list.sort` or |MiniVisits.gen_sort.default()|
615
+ as its default.
616
+
617
+ Return ~
618
+ `(table)` Array of available labels.
619
+
620
+ ------------------------------------------------------------------------------
621
+ *MiniVisits.select_path()*
622
+ `MiniVisits.select_path`({cwd}, {opts})
623
+ Select visit path
624
+
625
+ Uses |vim.ui.select()| with an output of |MiniVisits.list_paths()| and
626
+ calls |:edit| on the chosen item.
627
+
628
+ Note: if you have |mini.pick|, consider using |MiniExtra.pickers.visit_labels()|
629
+ and |MiniExtra.pickers.visit_paths()|.
630
+
631
+ Examples:
632
+
633
+ - Select from all visited paths: `MiniVisits.select_path('')`
634
+
635
+ - Select from paths under current directory sorted from most to least recent: >lua
636
+
637
+ local sort_recent = MiniVisits.gen_sort.default({ recency_weight = 1 })
638
+ MiniVisits.select_path(nil, { sort = sort_recent })
639
+ <
640
+ Parameters ~
641
+ {cwd} `(string|nil)` Forwarded to |MiniVisits.list_paths()|.
642
+ {opts} `(table|nil)` Forwarded to |MiniVisits.list_paths()|.
643
+
644
+ ------------------------------------------------------------------------------
645
+ *MiniVisits.select_label()*
646
+ `MiniVisits.select_label`({path}, {cwd}, {opts})
647
+ Select visit label
648
+
649
+ Uses |vim.ui.select()| with an output of |MiniVisits.list_labels()| and
650
+ calls |MiniVisits.select_path()| to get target paths with selected label.
651
+
652
+ Note: if you have |mini.pick|, consider using |MiniExtra.pickers.visit_labels()|.
653
+
654
+ Examples:
655
+
656
+ - Select from labels of current path: `MiniVisits.select_label()`
657
+
658
+ - Select from all visited labels: `MiniVisits.select_label('', '')`
659
+
660
+ - Select from current project labels and sort paths (after choosing) from most
661
+ to least recent: >lua
662
+
663
+ local sort_recent = MiniVisits.gen_sort.default({ recency_weight = 1 })
664
+ MiniVisits.select_label('', nil, { sort = sort_recent })
665
+ <
666
+ Parameters ~
667
+ {path} `(string|nil)` Forwarded to |MiniVisits.list_labels()|.
668
+ {cwd} `(string|nil)` Forwarded to |MiniVisits.list_labels()|.
669
+ {opts} `(table|nil)` Forwarded to both |MiniVisits.list_labels()|
670
+ and |MiniVisits.select_path()| (after choosing a label).
671
+
672
+ ------------------------------------------------------------------------------
673
+ *MiniVisits.iterate_paths()*
674
+ `MiniVisits.iterate_paths`({direction}, {cwd}, {opts})
675
+ Iterate visit paths
676
+
677
+ Steps:
678
+ - Compute a sorted array of target paths using |MiniVisits.list_paths()|.
679
+ - Identify the current index inside the array based on path of current buffer.
680
+ - Iterate through the array certain amount of times in a dedicated direction:
681
+ - For "first" direction - forward starting from index 0 (so that single
682
+ first iteration leads to first path).
683
+ - For "backward" direction - backward starting from current index.
684
+ - For "forward" direction - forward starting from current index.
685
+ - For "last" direction - backward starting from index after the last one
686
+ (so that single first iteration leads to the last path).
687
+
688
+ Notes:
689
+ - Mostly designed to be used as a mapping. See `MiniVisits-examples`.
690
+ - If path from current buffer is not in the output of `MiniVisits.list_paths()`,
691
+ starting index is inferred such that first iteration lands on first item
692
+ (if iterating forward) or last item (if iterating backward).
693
+ - Navigation with this function is not tracked (see |MiniVisits-overview|).
694
+ This is done to allow consecutive application without affecting
695
+ underlying list of paths.
696
+
697
+ Examples assuming underlying array of files `{ "file1", "file2", "file3" }`:
698
+
699
+ - `MiniVisits("first")` results into focusing on "file1".
700
+ - `MiniVisits("backward", { n_times = 2 })` from "file3" results into "file1".
701
+ - `MiniVisits("forward", { n_times = 10 })` from "file1" results into "file3".
702
+ - `MiniVisits("last", { n_times = 4, wrap = true })` results into "file3".
703
+
704
+ Parameters ~
705
+ {direction} `(string)` One of "first", "backward", "forward", "last".
706
+ {cwd} `(string|nil)` Forwarded to |MiniVisits.list_paths()|.
707
+ {opts} `(table|nil)` Options. Possible fields:
708
+ - <filter> `(function)` - forwarded to |MiniVisits.list_paths()|.
709
+ - <sort> `(function)` - forwarded to |MiniVisits.list_paths()|.
710
+ - <n_times> `(number)` - number of steps to go in certain direction.
711
+ Default: |v:count1|.
712
+ - <wrap> `(boolean)` - whether to wrap around list edges. Default: `false`.
713
+
714
+ ------------------------------------------------------------------------------
715
+ *MiniVisits.get_index()*
716
+ `MiniVisits.get_index`()
717
+ Get active visit index
718
+
719
+ Return ~
720
+ `(table)` Copy of currently active visit index table.
721
+
722
+ ------------------------------------------------------------------------------
723
+ *MiniVisits.set_index()*
724
+ `MiniVisits.set_index`({index})
725
+ Set active visit index
726
+
727
+ Parameters ~
728
+ {index} `(table)` Visit index table.
729
+
730
+ ------------------------------------------------------------------------------
731
+ *MiniVisits.reset_index()*
732
+ `MiniVisits.reset_index`()
733
+ Reset active visit index
734
+
735
+ Set currently active visit index to the output of |MiniVisits.read_index()|.
736
+ Does nothing if reading the index failed.
737
+
738
+ ------------------------------------------------------------------------------
739
+ *MiniVisits.normalize_index()*
740
+ `MiniVisits.normalize_index`({index})
741
+ Normalize visit index
742
+
743
+ Applies `config.store.normalize` (|MiniVisits.gen_normalize.default()| by default)
744
+ to the input index object and returns the output (if it fits in the definition
745
+ of index object; see |MiniVisits-index-specification|).
746
+
747
+ Parameters ~
748
+ {index} `(table|nil)` Index object. Default: copy of the current index.
749
+
750
+ Return ~
751
+ `(table)` Normalized index object.
752
+
753
+ ------------------------------------------------------------------------------
754
+ *MiniVisits.read_index()*
755
+ `MiniVisits.read_index`({store_path})
756
+ Read visit index from disk
757
+
758
+ Parameters ~
759
+ {store_path} `(string|nil)` Path on the disk containing visit index data.
760
+ Default: `config.store.path`.
761
+ Notes:
762
+ - Can return `nil` if path is empty string or file is not readable.
763
+ - File is sourced with |dofile()| as a regular Lua file.
764
+
765
+ Return ~
766
+ `(table|nil)` Output of the file source.
767
+
768
+ ------------------------------------------------------------------------------
769
+ *MiniVisits.write_index()*
770
+ `MiniVisits.write_index`({store_path}, {index})
771
+ Write visit index to disk
772
+
773
+ Steps:
774
+ - Normalize index with |MiniVisits.normalize_index()|.
775
+ - Ensure path is valid (all parent directories are created, etc.).
776
+ - Write index object to the path so that it is readable
777
+ with |MiniVisits.read_index()|.
778
+
779
+ Parameters ~
780
+ {store_path} `(string|nil)` Path on the disk where to write visit index data.
781
+ Default: `config.store.path`. Note: if empty string, nothing is written.
782
+ {index} `(table|nil)` Index object to write to disk.
783
+ Default: current session index.
784
+
785
+ ------------------------------------------------------------------------------
786
+ *MiniVisits.rename_in_index()*
787
+ `MiniVisits.rename_in_index`({path_from}, {path_to}, {index})
788
+ Rename path in index
789
+
790
+ A helper to react for a path rename/move in order to preserve its visit data.
791
+ It works both for file and directory paths.
792
+
793
+ Notes:
794
+ - It does not update current index, but returns a modified index object.
795
+ Use |MiniVisits.set_index()| to make it current.
796
+ - Use only full paths.
797
+ - Do not append `/` to directory paths. Use same format as for files.
798
+
799
+ Assuming `path_from` and `path_to` are variables containing full paths
800
+ before and after rename/move, here is an example to update current index: >lua
801
+
802
+ local new_index = MiniVisits.rename_in_index(path_from, path_to)
803
+ MiniVisits.set_index(new_index)
804
+ <
805
+ Parameters ~
806
+ {path_from} `(string)` Full path to be renamed.
807
+ {path_to} `(string)` Full path to be replaced with.
808
+ {index} `(table|nil)` Index object inside which to perform renaming.
809
+ Default: current session index.
810
+
811
+ Return ~
812
+ `(table)` Index object with renamed path.
813
+
814
+ ------------------------------------------------------------------------------
815
+ *MiniVisits.gen_filter*
816
+ `MiniVisits.gen_filter`
817
+ Generate filter function
818
+
819
+ This is a table with function elements. Call to actually get specification.
820
+
821
+ ------------------------------------------------------------------------------
822
+ *MiniVisits.gen_filter.default()*
823
+ `MiniVisits.gen_filter.default`()
824
+ Default filter
825
+
826
+ Always returns `true` resulting in no actual filter.
827
+
828
+ Return ~
829
+ `(function)` Visit filter function. See |MiniVisits.config.list| for more details.
830
+
831
+ ------------------------------------------------------------------------------
832
+ *MiniVisits.gen_filter.this_session()*
833
+ `MiniVisits.gen_filter.this_session`()
834
+ Filter visits from current session
835
+
836
+ Return ~
837
+ `(function)` Visit filter function. See |MiniVisits.config.list| for more details.
838
+
839
+ ------------------------------------------------------------------------------
840
+ *MiniVisits.gen_sort*
841
+ `MiniVisits.gen_sort`
842
+ Generate sort function
843
+
844
+ This is a table with function elements. Call to actually get specification.
845
+
846
+ ------------------------------------------------------------------------------
847
+ *MiniVisits.gen_sort.default()*
848
+ `MiniVisits.gen_sort.default`({opts})
849
+ Default sort
850
+
851
+ Sort paths using "robust frecency" approach. It relies on the rank operation:
852
+ based on certain reference number for every item, assign it a number
853
+ between 1 (best) and number of items (worst). Ties are dealt with "average
854
+ rank" approach: each element with a same reference number is assigned
855
+ an average rank among such elements. This way total rank sum depends only
856
+ on number of paths.
857
+
858
+ Here is an algorithm outline:
859
+ - Rank paths based on frequency (`count` value): from most to least frequent.
860
+ - Rank paths based on recency (`latest` value): from most to least recent.
861
+ - Combine ranks from previous steps with weights:
862
+ `score = (1 - w) * rank_frequency + w * rank_recency`, where `w` is
863
+ "recency weight". The smaller this weight the less recency affects outcome.
864
+
865
+ Examples:
866
+ - Default recency weight 0.5 results into "robust frecency" sorting: it
867
+ combines both frequency and recency.
868
+ This is called a "robust frecency" because actual values don't have direct
869
+ effect on the outcome, only ordering matters. For example, if there is
870
+ a very frequent file with `count = 100` while all others have `count = 5`,
871
+ it will not massively dominate the outcome as long as it is not very recent.
872
+
873
+ - Having recency weight 1 results into "from most to least recent" sorting.
874
+
875
+ - Having recency weight 0 results into "from most to least frequent" sorting.
876
+
877
+ Parameters ~
878
+ {opts} `(table|nil)` Option. Possible fields:
879
+ - <recency_weight> `(number)` - a number between 0 and 1 for recency weight.
880
+ Default: 0.5.
881
+
882
+ Return ~
883
+ `(function)` Visit sort function. See |MiniVisits.config.list| for more details.
884
+
885
+ ------------------------------------------------------------------------------
886
+ *MiniVisits.gen_sort.z()*
887
+ `MiniVisits.gen_sort.z`()
888
+ Z sort
889
+
890
+ Sort as in https://github.com/rupa/z.
891
+
892
+ Return ~
893
+ `(function)` Visit sort function. See |MiniVisits.config.list| for more details.
894
+
895
+ ------------------------------------------------------------------------------
896
+ *MiniVisits.gen_normalize*
897
+ `MiniVisits.gen_normalize`
898
+ Generate normalize function
899
+
900
+ This is a table with function elements. Call to actually get specification.
901
+
902
+ ------------------------------------------------------------------------------
903
+ *MiniVisits.gen_normalize.default()*
904
+ `MiniVisits.gen_normalize.default`({opts})
905
+ Generate default normalize function
906
+
907
+ Steps:
908
+ - Prune visits, i.e. remove outdated visits:
909
+ - If `count` number of visits is below prune threshold, remove that visit
910
+ entry from particular cwd (it can still be present in others).
911
+ - If either first (cwd) or second (path) level key doesn't represent an
912
+ actual path on disk, remove the whole associated value.
913
+ - NOTE: if visit has any label, it is not automatically pruned.
914
+
915
+ - Decay visits, i.e. possibly make visits more outdated. This is an important
916
+ part to the whole usability: together with pruning it results into automated
917
+ removing of paths which were visited long ago and are not relevant.
918
+
919
+ Decay is done per cwd if its total `count` values sum exceeds decay threshold.
920
+ It is performed through multiplying each `count` by same coefficient so that
921
+ the new total sum of `count` is equal to some smaller target value.
922
+ Note: only two decimal places are preserved, so the sum might not be exact.
923
+
924
+ - Prune once more to ensure that there are no outdated paths after decay.
925
+
926
+ Parameters ~
927
+ {opts} `(table|nil)` Options. Possible fields:
928
+ - <decay_threshold> `(number)` - decay threshold. Default: 1000.
929
+ - <decay_target> `(number)` - decay target. Default: 800.
930
+ - <prune_threshold> `(number)` - prune threshold. Default: 0.5.
931
+ - <prune_paths> `(boolean)` - whether to prune outdated paths. Default: `true`.
932
+
933
+ Return ~
934
+ `(function)` Visit index normalize function. See "Store" in |MiniVisits.config|.
935
+
936
+
937
+ vim:tw=78:ts=8:noet:ft=help:norl: