retrovim 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.conda/retrovim.yaml +259 -0
- package/.conda/terax.icns +0 -0
- package/.conda/terax.ico +0 -0
- package/.conda/terax.png +0 -0
- package/.github/workflows/release.yml +95 -0
- package/.gitmodules +3 -0
- package/.npm/kanata_touchcursor.js +28 -0
- package/.npm/nvim.js +26 -0
- package/.npm/yazi.js +26 -0
- package/.npm/zsh.js +17 -0
- package/.pip/kanata_touchcursor/__init__.py +28 -0
- package/.pip/nvim/__init__.py +31 -0
- package/.pip/yazi/__init__.py +31 -0
- package/.pip/zsh/__init__.py +22 -0
- package/CHANGELOG.md +26 -0
- package/LICENSE +674 -0
- package/README.md +336 -0
- package/kanata/touchcursor.kbd +164 -0
- package/nvim/init.lua +813 -0
- package/nvim/plugins/mini.nvim/.github/DISCUSSION_TEMPLATE/q-a.yml +72 -0
- package/nvim/plugins/mini.nvim/.github/ISSUE_TEMPLATE/bug-report.yml +136 -0
- package/nvim/plugins/mini.nvim/.github/ISSUE_TEMPLATE/config.yml +5 -0
- package/nvim/plugins/mini.nvim/.github/ISSUE_TEMPLATE/feature-request.yml +75 -0
- package/nvim/plugins/mini.nvim/.github/PULL_REQUEST_TEMPLATE.md +2 -0
- package/nvim/plugins/mini.nvim/.github/workflows/quality-control.yml +150 -0
- package/nvim/plugins/mini.nvim/.pre-commit-config.yaml +20 -0
- package/nvim/plugins/mini.nvim/.stylua.toml +7 -0
- package/nvim/plugins/mini.nvim/.styluaignore +1 -0
- package/nvim/plugins/mini.nvim/CHANGELOG.md +1894 -0
- package/nvim/plugins/mini.nvim/CODE_OF_CONDUCT.md +132 -0
- package/nvim/plugins/mini.nvim/CONTRIBUTING.md +331 -0
- package/nvim/plugins/mini.nvim/LICENSE +21 -0
- package/nvim/plugins/mini.nvim/MAINTAINING.md +330 -0
- package/nvim/plugins/mini.nvim/Makefile +51 -0
- package/nvim/plugins/mini.nvim/README.md +261 -0
- package/nvim/plugins/mini.nvim/TESTING.md +1011 -0
- package/nvim/plugins/mini.nvim/benchmarks/starter/README.md +35 -0
- package/nvim/plugins/mini.nvim/benchmarks/starter/benchmark.sh +56 -0
- package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_dashboard-alpha.lua +21 -0
- package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_dashboard-original.lua +17 -0
- package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_dashboard-starter.lua +18 -0
- package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_empty.lua +4 -0
- package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_starter-default.lua +7 -0
- package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_startify-alpha.lua +10 -0
- package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_startify-original.lua +7 -0
- package/nvim/plugins/mini.nvim/benchmarks/starter/init-files/init_startify-starter.lua +20 -0
- package/nvim/plugins/mini.nvim/benchmarks/starter/install.sh +10 -0
- package/nvim/plugins/mini.nvim/benchmarks/starter/make_summary.py +68 -0
- package/nvim/plugins/mini.nvim/benchmarks/starter/startup-summary.md +10 -0
- package/nvim/plugins/mini.nvim/colors/miniautumn.lua +55 -0
- package/nvim/plugins/mini.nvim/colors/minicyan.lua +95 -0
- package/nvim/plugins/mini.nvim/colors/minischeme.lua +95 -0
- package/nvim/plugins/mini.nvim/colors/minispring.lua +53 -0
- package/nvim/plugins/mini.nvim/colors/minisummer.lua +49 -0
- package/nvim/plugins/mini.nvim/colors/miniwinter.lua +51 -0
- package/nvim/plugins/mini.nvim/colors/randomhue.lua +16 -0
- package/nvim/plugins/mini.nvim/doc/mini-ai.txt +889 -0
- package/nvim/plugins/mini.nvim/doc/mini-align.txt +923 -0
- package/nvim/plugins/mini.nvim/doc/mini-animate.txt +937 -0
- package/nvim/plugins/mini.nvim/doc/mini-base16.txt +285 -0
- package/nvim/plugins/mini.nvim/doc/mini-basics.txt +359 -0
- package/nvim/plugins/mini.nvim/doc/mini-bracketed.txt +622 -0
- package/nvim/plugins/mini.nvim/doc/mini-bufremove.txt +123 -0
- package/nvim/plugins/mini.nvim/doc/mini-clue.txt +760 -0
- package/nvim/plugins/mini.nvim/doc/mini-cmdline.txt +392 -0
- package/nvim/plugins/mini.nvim/doc/mini-colors.txt +880 -0
- package/nvim/plugins/mini.nvim/doc/mini-comment.txt +230 -0
- package/nvim/plugins/mini.nvim/doc/mini-completion.txt +477 -0
- package/nvim/plugins/mini.nvim/doc/mini-cursorword.txt +105 -0
- package/nvim/plugins/mini.nvim/doc/mini-deps.txt +590 -0
- package/nvim/plugins/mini.nvim/doc/mini-diff.txt +661 -0
- package/nvim/plugins/mini.nvim/doc/mini-doc.txt +434 -0
- package/nvim/plugins/mini.nvim/doc/mini-extra.txt +856 -0
- package/nvim/plugins/mini.nvim/doc/mini-files.txt +1018 -0
- package/nvim/plugins/mini.nvim/doc/mini-fuzzy.txt +160 -0
- package/nvim/plugins/mini.nvim/doc/mini-git.txt +425 -0
- package/nvim/plugins/mini.nvim/doc/mini-hipatterns.txt +489 -0
- package/nvim/plugins/mini.nvim/doc/mini-hues.txt +420 -0
- package/nvim/plugins/mini.nvim/doc/mini-icons.txt +508 -0
- package/nvim/plugins/mini.nvim/doc/mini-indentscope.txt +485 -0
- package/nvim/plugins/mini.nvim/doc/mini-input.txt +932 -0
- package/nvim/plugins/mini.nvim/doc/mini-jump.txt +202 -0
- package/nvim/plugins/mini.nvim/doc/mini-jump2d.txt +525 -0
- package/nvim/plugins/mini.nvim/doc/mini-keymap.txt +449 -0
- package/nvim/plugins/mini.nvim/doc/mini-map.txt +717 -0
- package/nvim/plugins/mini.nvim/doc/mini-misc.txt +431 -0
- package/nvim/plugins/mini.nvim/doc/mini-move.txt +181 -0
- package/nvim/plugins/mini.nvim/doc/mini-notify.txt +434 -0
- package/nvim/plugins/mini.nvim/doc/mini-nvim.txt +431 -0
- package/nvim/plugins/mini.nvim/doc/mini-operators.txt +472 -0
- package/nvim/plugins/mini.nvim/doc/mini-pairs.txt +346 -0
- package/nvim/plugins/mini.nvim/doc/mini-pick.txt +1535 -0
- package/nvim/plugins/mini.nvim/doc/mini-sessions.txt +239 -0
- package/nvim/plugins/mini.nvim/doc/mini-snippets.txt +1291 -0
- package/nvim/plugins/mini.nvim/doc/mini-splitjoin.txt +536 -0
- package/nvim/plugins/mini.nvim/doc/mini-starter.txt +618 -0
- package/nvim/plugins/mini.nvim/doc/mini-statusline.txt +361 -0
- package/nvim/plugins/mini.nvim/doc/mini-surround.txt +863 -0
- package/nvim/plugins/mini.nvim/doc/mini-tabline.txt +151 -0
- package/nvim/plugins/mini.nvim/doc/mini-test.txt +966 -0
- package/nvim/plugins/mini.nvim/doc/mini-trailspace.txt +91 -0
- package/nvim/plugins/mini.nvim/doc/mini-visits.txt +937 -0
- package/nvim/plugins/mini.nvim/logo.png +0 -0
- package/nvim/plugins/mini.nvim/lua/mini/ai.lua +2244 -0
- package/nvim/plugins/mini.nvim/lua/mini/align.lua +2076 -0
- package/nvim/plugins/mini.nvim/lua/mini/animate.lua +2127 -0
- package/nvim/plugins/mini.nvim/lua/mini/base16.lua +1752 -0
- package/nvim/plugins/mini.nvim/lua/mini/basics.lua +772 -0
- package/nvim/plugins/mini.nvim/lua/mini/bracketed.lua +2013 -0
- package/nvim/plugins/mini.nvim/lua/mini/bufremove.lua +283 -0
- package/nvim/plugins/mini.nvim/lua/mini/clue.lua +2096 -0
- package/nvim/plugins/mini.nvim/lua/mini/cmdline.lua +1182 -0
- package/nvim/plugins/mini.nvim/lua/mini/colors.lua +2483 -0
- package/nvim/plugins/mini.nvim/lua/mini/comment.lua +586 -0
- package/nvim/plugins/mini.nvim/lua/mini/completion.lua +2094 -0
- package/nvim/plugins/mini.nvim/lua/mini/cursorword.lua +311 -0
- package/nvim/plugins/mini.nvim/lua/mini/deps.lua +1660 -0
- package/nvim/plugins/mini.nvim/lua/mini/diff.lua +1938 -0
- package/nvim/plugins/mini.nvim/lua/mini/doc.lua +1371 -0
- package/nvim/plugins/mini.nvim/lua/mini/extra.lua +2290 -0
- package/nvim/plugins/mini.nvim/lua/mini/files.lua +3145 -0
- package/nvim/plugins/mini.nvim/lua/mini/fuzzy.lua +356 -0
- package/nvim/plugins/mini.nvim/lua/mini/git.lua +1737 -0
- package/nvim/plugins/mini.nvim/lua/mini/hipatterns.lua +1042 -0
- package/nvim/plugins/mini.nvim/lua/mini/hues.lua +2088 -0
- package/nvim/plugins/mini.nvim/lua/mini/icons.lua +2254 -0
- package/nvim/plugins/mini.nvim/lua/mini/indentscope.lua +1158 -0
- package/nvim/plugins/mini.nvim/lua/mini/init.lua +427 -0
- package/nvim/plugins/mini.nvim/lua/mini/input.lua +2183 -0
- package/nvim/plugins/mini.nvim/lua/mini/jump.lua +609 -0
- package/nvim/plugins/mini.nvim/lua/mini/jump2d.lua +1244 -0
- package/nvim/plugins/mini.nvim/lua/mini/keymap.lua +880 -0
- package/nvim/plugins/mini.nvim/lua/mini/map.lua +1709 -0
- package/nvim/plugins/mini.nvim/lua/mini/misc.lua +969 -0
- package/nvim/plugins/mini.nvim/lua/mini/move.lua +509 -0
- package/nvim/plugins/mini.nvim/lua/mini/notify.lua +938 -0
- package/nvim/plugins/mini.nvim/lua/mini/operators.lua +1349 -0
- package/nvim/plugins/mini.nvim/lua/mini/pairs.lua +657 -0
- package/nvim/plugins/mini.nvim/lua/mini/pick.lua +3876 -0
- package/nvim/plugins/mini.nvim/lua/mini/sessions.lua +689 -0
- package/nvim/plugins/mini.nvim/lua/mini/snippets.lua +2828 -0
- package/nvim/plugins/mini.nvim/lua/mini/splitjoin.lua +1132 -0
- package/nvim/plugins/mini.nvim/lua/mini/starter.lua +1599 -0
- package/nvim/plugins/mini.nvim/lua/mini/statusline.lua +686 -0
- package/nvim/plugins/mini.nvim/lua/mini/surround.lua +2388 -0
- package/nvim/plugins/mini.nvim/lua/mini/tabline.lua +564 -0
- package/nvim/plugins/mini.nvim/lua/mini/test.lua +2516 -0
- package/nvim/plugins/mini.nvim/lua/mini/trailspace.lua +215 -0
- package/nvim/plugins/mini.nvim/lua/mini/visits.lua +1577 -0
- package/nvim/plugins/mini.nvim/readmes/mini-ai.md +190 -0
- package/nvim/plugins/mini.nvim/readmes/mini-align.md +203 -0
- package/nvim/plugins/mini.nvim/readmes/mini-animate.md +214 -0
- package/nvim/plugins/mini.nvim/readmes/mini-base16.md +198 -0
- package/nvim/plugins/mini.nvim/readmes/mini-basics.md +184 -0
- package/nvim/plugins/mini.nvim/readmes/mini-bracketed.md +193 -0
- package/nvim/plugins/mini.nvim/readmes/mini-bufremove.md +139 -0
- package/nvim/plugins/mini.nvim/readmes/mini-clue.md +260 -0
- package/nvim/plugins/mini.nvim/readmes/mini-cmdline.md +183 -0
- package/nvim/plugins/mini.nvim/readmes/mini-colors.md +169 -0
- package/nvim/plugins/mini.nvim/readmes/mini-comment.md +183 -0
- package/nvim/plugins/mini.nvim/readmes/mini-completion.md +217 -0
- package/nvim/plugins/mini.nvim/readmes/mini-cursorword.md +137 -0
- package/nvim/plugins/mini.nvim/readmes/mini-deps.md +271 -0
- package/nvim/plugins/mini.nvim/readmes/mini-diff.md +289 -0
- package/nvim/plugins/mini.nvim/readmes/mini-doc.md +198 -0
- package/nvim/plugins/mini.nvim/readmes/mini-extra.md +158 -0
- package/nvim/plugins/mini.nvim/readmes/mini-files.md +247 -0
- package/nvim/plugins/mini.nvim/readmes/mini-fuzzy.md +134 -0
- package/nvim/plugins/mini.nvim/readmes/mini-git.md +168 -0
- package/nvim/plugins/mini.nvim/readmes/mini-hipatterns.md +176 -0
- package/nvim/plugins/mini.nvim/readmes/mini-hues.md +285 -0
- package/nvim/plugins/mini.nvim/readmes/mini-icons.md +183 -0
- package/nvim/plugins/mini.nvim/readmes/mini-indentscope.md +191 -0
- package/nvim/plugins/mini.nvim/readmes/mini-input.md +163 -0
- package/nvim/plugins/mini.nvim/readmes/mini-jump.md +161 -0
- package/nvim/plugins/mini.nvim/readmes/mini-jump2d.md +197 -0
- package/nvim/plugins/mini.nvim/readmes/mini-keymap.md +205 -0
- package/nvim/plugins/mini.nvim/readmes/mini-map.md +191 -0
- package/nvim/plugins/mini.nvim/readmes/mini-misc.md +145 -0
- package/nvim/plugins/mini.nvim/readmes/mini-move.md +163 -0
- package/nvim/plugins/mini.nvim/readmes/mini-notify.md +175 -0
- package/nvim/plugins/mini.nvim/readmes/mini-operators.md +193 -0
- package/nvim/plugins/mini.nvim/readmes/mini-pairs.md +158 -0
- package/nvim/plugins/mini.nvim/readmes/mini-pick.md +340 -0
- package/nvim/plugins/mini.nvim/readmes/mini-sessions.md +164 -0
- package/nvim/plugins/mini.nvim/readmes/mini-snippets.md +373 -0
- package/nvim/plugins/mini.nvim/readmes/mini-splitjoin.md +194 -0
- package/nvim/plugins/mini.nvim/readmes/mini-starter.md +176 -0
- package/nvim/plugins/mini.nvim/readmes/mini-statusline.md +155 -0
- package/nvim/plugins/mini.nvim/readmes/mini-surround.md +190 -0
- package/nvim/plugins/mini.nvim/readmes/mini-tabline.md +156 -0
- package/nvim/plugins/mini.nvim/readmes/mini-test.md +175 -0
- package/nvim/plugins/mini.nvim/readmes/mini-trailspace.md +137 -0
- package/nvim/plugins/mini.nvim/readmes/mini-visits.md +243 -0
- package/nvim/plugins/mini.nvim/scripts/dual_log.sh +13 -0
- package/nvim/plugins/mini.nvim/scripts/dual_push.sh +15 -0
- package/nvim/plugins/mini.nvim/scripts/dual_release.sh +102 -0
- package/nvim/plugins/mini.nvim/scripts/dual_sync.sh +115 -0
- package/nvim/plugins/mini.nvim/scripts/init-deps-example.lua +59 -0
- package/nvim/plugins/mini.nvim/scripts/lint-filename-length.sh +16 -0
- package/nvim/plugins/mini.nvim/scripts/lintcommit-ci.sh +18 -0
- package/nvim/plugins/mini.nvim/scripts/lintcommit.lua +393 -0
- package/nvim/plugins/mini.nvim/scripts/minidoc.lua +57 -0
- package/nvim/plugins/mini.nvim/scripts/minimal_init.lua +28 -0
- package/nvim/plugins/mini.nvim/scripts/minitest.lua +4 -0
- package/package.json +16 -0
- package/pyproject.toml +43 -0
- package/yazi/init.lua +12 -0
- package/yazi/keymap.toml +114 -0
- package/yazi/lesskey +5 -0
- package/yazi/plugins/bookmarks.yazi/main.lua +86 -0
- package/yazi/plugins/cd-git-root.yazi/main.lua +31 -0
- package/yazi/plugins/smart-enter.yazi/main.lua +11 -0
- package/yazi/theme.toml +26 -0
- package/yazi/yazi.toml +15 -0
- package/zsh/.zshrc +145 -0
- package/zsh/starship.toml +20 -0
- package/zsh/zsh-patina.toml +2 -0
|
@@ -0,0 +1,686 @@
|
|
|
1
|
+
--- *mini.statusline* Statusline
|
|
2
|
+
---
|
|
3
|
+
--- MIT License Copyright (c) 2021 Evgeni Chasnovski
|
|
4
|
+
|
|
5
|
+
--- Features:
|
|
6
|
+
--- - Define own custom statusline structure for active and inactive windows.
|
|
7
|
+
--- This is done with a function which should return string appropriate for
|
|
8
|
+
--- |'statusline'|. Its code should be similar to default one with structure:
|
|
9
|
+
--- - Compute string data for every section you want to be displayed.
|
|
10
|
+
--- - Combine them in groups with |MiniStatusline.combine_groups()|.
|
|
11
|
+
---
|
|
12
|
+
--- - Built-in active mode indicator with colors.
|
|
13
|
+
---
|
|
14
|
+
--- - Sections can hide information when window is too narrow (specific window
|
|
15
|
+
--- width is configurable per section).
|
|
16
|
+
---
|
|
17
|
+
--- # Dependencies ~
|
|
18
|
+
---
|
|
19
|
+
--- Suggested dependencies (provide extra functionality, will work without them):
|
|
20
|
+
---
|
|
21
|
+
--- - Nerd font (to support extra icons).
|
|
22
|
+
---
|
|
23
|
+
--- - Enabled |mini.icons| module for |MiniStatusline.section_fileinfo()|.
|
|
24
|
+
--- Falls back to using `nvim-tree/nvim-web-devicons` plugin or shows nothing.
|
|
25
|
+
---
|
|
26
|
+
--- - Enabled |mini.git| module for |MiniStatusline.section_git()|.
|
|
27
|
+
--- Falls back to using `lewis6991/gitsigns.nvim` plugin or shows nothing.
|
|
28
|
+
---
|
|
29
|
+
--- - Enabled |mini.diff| module for |MiniStatusline.section_diff()|.
|
|
30
|
+
--- Falls back to using `lewis6991/gitsigns.nvim` plugin or shows nothing.
|
|
31
|
+
---
|
|
32
|
+
--- # Setup ~
|
|
33
|
+
---
|
|
34
|
+
--- This module needs a setup with `require('mini.statusline').setup({})`
|
|
35
|
+
--- (replace `{}` with your `config` table). It will create global Lua table
|
|
36
|
+
--- `MiniStatusline` which you can use for scripting or manually (with
|
|
37
|
+
--- `:lua MiniStatusline.*`).
|
|
38
|
+
---
|
|
39
|
+
--- See |MiniStatusline.config| for `config` structure and default values. For
|
|
40
|
+
--- some content examples, see |MiniStatusline-example-content|.
|
|
41
|
+
---
|
|
42
|
+
--- You can override runtime config settings locally to buffer inside
|
|
43
|
+
--- `vim.b.ministatusline_config` which should have same structure as
|
|
44
|
+
--- `MiniStatusline.config`. See |mini.nvim-buffer-local-config| for more details.
|
|
45
|
+
---
|
|
46
|
+
--- # Highlight groups ~
|
|
47
|
+
--- *MiniStatusline-hl-groups*
|
|
48
|
+
---
|
|
49
|
+
--- Highlight depending on mode (second |MiniStatusline.section_mode()| output):
|
|
50
|
+
--- - `MiniStatuslineModeNormal` - Normal mode.
|
|
51
|
+
--- - `MiniStatuslineModeInsert` - Insert mode.
|
|
52
|
+
--- - `MiniStatuslineModeVisual` - Visual mode.
|
|
53
|
+
--- - `MiniStatuslineModeReplace` - Replace mode.
|
|
54
|
+
--- - `MiniStatuslineModeCommand` - Command mode.
|
|
55
|
+
--- - `MiniStatuslineModeOther` - other modes (like Terminal, etc.).
|
|
56
|
+
---
|
|
57
|
+
--- Highlight used in default statusline:
|
|
58
|
+
--- - `MiniStatuslineDevinfo` - for "dev info" group
|
|
59
|
+
--- (|MiniStatusline.section_git()| and |MiniStatusline.section_diagnostics()|).
|
|
60
|
+
--- - `MiniStatuslineFilename` - for |MiniStatusline.section_filename()| section.
|
|
61
|
+
--- - `MiniStatuslineFileinfo` - for |MiniStatusline.section_fileinfo()| section.
|
|
62
|
+
---
|
|
63
|
+
--- Other groups:
|
|
64
|
+
--- - `MiniStatuslineInactive` - highlighting in not focused window.
|
|
65
|
+
---
|
|
66
|
+
--- To change any highlight group, set it directly with |nvim_set_hl()|.
|
|
67
|
+
---
|
|
68
|
+
--- # Disabling ~
|
|
69
|
+
---
|
|
70
|
+
--- To disable (show empty statusline), set `vim.g.ministatusline_disable`
|
|
71
|
+
--- (globally) or `vim.b.ministatusline_disable` (for a buffer) to `true`.
|
|
72
|
+
--- Considering high number of different scenarios and customization
|
|
73
|
+
--- intentions, writing exact rules for disabling module's functionality is
|
|
74
|
+
--- left to user. See |mini.nvim-disabling-recipes| for common recipes.
|
|
75
|
+
---@tag MiniStatusline
|
|
76
|
+
|
|
77
|
+
--- Example content
|
|
78
|
+
---
|
|
79
|
+
--- # Default content ~
|
|
80
|
+
---
|
|
81
|
+
--- This function is used as default value for active content: >lua
|
|
82
|
+
---
|
|
83
|
+
--- function()
|
|
84
|
+
--- local mode, mode_hl = MiniStatusline.section_mode({ trunc_width = 120 })
|
|
85
|
+
--- local git = MiniStatusline.section_git({ trunc_width = 40 })
|
|
86
|
+
--- local diff = MiniStatusline.section_diff({ trunc_width = 75 })
|
|
87
|
+
--- local diagnostics = MiniStatusline.section_diagnostics({ trunc_width = 75 })
|
|
88
|
+
--- local lsp = MiniStatusline.section_lsp({ trunc_width = 75 })
|
|
89
|
+
--- local filename = MiniStatusline.section_filename({ trunc_width = 140 })
|
|
90
|
+
--- local fileinfo = MiniStatusline.section_fileinfo({ trunc_width = 120 })
|
|
91
|
+
--- local location = MiniStatusline.section_location({ trunc_width = 75 })
|
|
92
|
+
--- local search = MiniStatusline.section_searchcount({ trunc_width = 75 })
|
|
93
|
+
---
|
|
94
|
+
--- return MiniStatusline.combine_groups({
|
|
95
|
+
--- { hl = mode_hl, strings = { mode } },
|
|
96
|
+
--- { hl = 'MiniStatuslineDevinfo', strings = { git, diff, diagnostics, lsp } },
|
|
97
|
+
--- '%<', -- Mark general truncate point
|
|
98
|
+
--- { hl = 'MiniStatuslineFilename', strings = { filename } },
|
|
99
|
+
--- '%=', -- End left alignment
|
|
100
|
+
--- { hl = 'MiniStatuslineFileinfo', strings = { fileinfo } },
|
|
101
|
+
--- { hl = mode_hl, strings = { search, location } },
|
|
102
|
+
--- })
|
|
103
|
+
--- end
|
|
104
|
+
--- <
|
|
105
|
+
--- # Show boolean options ~
|
|
106
|
+
---
|
|
107
|
+
--- To compute section string for boolean option use variation of this code
|
|
108
|
+
--- snippet inside content function (you can modify option itself, truncation
|
|
109
|
+
--- width, short and long displayed names): >lua
|
|
110
|
+
---
|
|
111
|
+
--- local spell = vim.wo.spell and (MiniStatusline.is_truncated(120) and 'S' or 'SPELL') or ''
|
|
112
|
+
--- <
|
|
113
|
+
--- Here `x and y or z` is a common Lua way of doing ternary operator: if `x`
|
|
114
|
+
--- is `true`-ish then return `y`, if not - return `z`.
|
|
115
|
+
---@tag MiniStatusline-example-content
|
|
116
|
+
|
|
117
|
+
---@alias __statusline_args table Section arguments.
|
|
118
|
+
---@alias __statusline_section string Section string.
|
|
119
|
+
|
|
120
|
+
-- Module definition ==========================================================
|
|
121
|
+
local MiniStatusline = {}
|
|
122
|
+
local H = {}
|
|
123
|
+
|
|
124
|
+
--- Module setup
|
|
125
|
+
---
|
|
126
|
+
---@param config table|nil Module config table. See |MiniStatusline.config|.
|
|
127
|
+
---
|
|
128
|
+
---@usage >lua
|
|
129
|
+
--- require('mini.statusline').setup() -- use default config
|
|
130
|
+
--- -- OR
|
|
131
|
+
--- require('mini.statusline').setup({}) -- replace {} with your config table
|
|
132
|
+
--- <
|
|
133
|
+
MiniStatusline.setup = function(config)
|
|
134
|
+
-- TODO: Remove after Neovim=0.9 support is dropped
|
|
135
|
+
if vim.fn.has('nvim-0.10') == 0 then
|
|
136
|
+
vim.notify(
|
|
137
|
+
'(mini.statusline) Neovim<0.10 is soft deprecated (module works but is not supported).'
|
|
138
|
+
.. " It will be deprecated after the next 'mini.nvim' release (module might not work)."
|
|
139
|
+
.. ' Please update your Neovim version.'
|
|
140
|
+
)
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
-- Export module
|
|
144
|
+
_G.MiniStatusline = MiniStatusline
|
|
145
|
+
|
|
146
|
+
-- Setup config
|
|
147
|
+
config = H.setup_config(config)
|
|
148
|
+
|
|
149
|
+
-- Apply config
|
|
150
|
+
H.apply_config(config)
|
|
151
|
+
|
|
152
|
+
-- Define behavior
|
|
153
|
+
H.create_autocommands()
|
|
154
|
+
|
|
155
|
+
-- - Disable built-in statusline in Quickfix window
|
|
156
|
+
vim.g.qf_disable_statusline = 1
|
|
157
|
+
|
|
158
|
+
-- Create default highlighting
|
|
159
|
+
H.create_default_hl()
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
--- Defaults ~
|
|
163
|
+
---@eval return MiniDoc.afterlines_to_code(MiniDoc.current.eval_section)
|
|
164
|
+
MiniStatusline.config = {
|
|
165
|
+
-- Content of statusline as functions which return statusline string. See
|
|
166
|
+
-- `:h statusline` and code of default contents (used instead of `nil`).
|
|
167
|
+
content = {
|
|
168
|
+
-- Content for active window
|
|
169
|
+
active = nil,
|
|
170
|
+
-- Content for inactive window(s)
|
|
171
|
+
inactive = nil,
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
-- Whether to use icons by default
|
|
175
|
+
use_icons = true,
|
|
176
|
+
}
|
|
177
|
+
--minidoc_afterlines_end
|
|
178
|
+
|
|
179
|
+
-- Module functionality =======================================================
|
|
180
|
+
--- Compute content for active window
|
|
181
|
+
MiniStatusline.active = function()
|
|
182
|
+
if H.is_disabled() then return '' end
|
|
183
|
+
return (H.get_config().content.active or H.default_content_active)()
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
--- Compute content for inactive window
|
|
187
|
+
MiniStatusline.inactive = function()
|
|
188
|
+
if H.is_disabled() then return '' end
|
|
189
|
+
return (H.get_config().content.inactive or H.default_content_inactive)()
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
--- Combine groups of sections
|
|
193
|
+
---
|
|
194
|
+
--- Each group can be either a string or a table with fields `hl` (group's
|
|
195
|
+
--- highlight group) and `strings` (strings representing sections).
|
|
196
|
+
---
|
|
197
|
+
--- General idea of this function is as follows;
|
|
198
|
+
--- - String group is used as is (useful for special strings like `%<` or `%=`).
|
|
199
|
+
--- - Each table group has own highlighting in `hl` field (if missing, the
|
|
200
|
+
--- previous one is used) and string parts in `strings` field. Non-empty
|
|
201
|
+
--- strings from `strings` are separated by one space. Non-empty groups are
|
|
202
|
+
--- separated by two spaces (one for each highlighting).
|
|
203
|
+
---
|
|
204
|
+
---@param groups table Array of groups.
|
|
205
|
+
---
|
|
206
|
+
---@return string String suitable for |'statusline'|.
|
|
207
|
+
MiniStatusline.combine_groups = function(groups)
|
|
208
|
+
local parts = vim.tbl_map(function(s)
|
|
209
|
+
if type(s) == 'string' then return s end
|
|
210
|
+
if type(s) ~= 'table' then return '' end
|
|
211
|
+
|
|
212
|
+
local string_arr = vim.tbl_filter(function(x) return type(x) == 'string' and x ~= '' end, s.strings or {})
|
|
213
|
+
local str = table.concat(string_arr, ' ')
|
|
214
|
+
|
|
215
|
+
-- Use previous highlight group
|
|
216
|
+
if s.hl == nil then return ' ' .. str .. ' ' end
|
|
217
|
+
|
|
218
|
+
-- Allow using this highlight group later
|
|
219
|
+
if str:len() == 0 then return '%#' .. s.hl .. '#' end
|
|
220
|
+
|
|
221
|
+
return string.format('%%#%s# %s ', s.hl, str)
|
|
222
|
+
end, groups)
|
|
223
|
+
|
|
224
|
+
return table.concat(parts, '')
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
--- Decide whether to truncate
|
|
228
|
+
---
|
|
229
|
+
--- This basically computes window width and compares it to `trunc_width`: if
|
|
230
|
+
--- window is smaller then truncate; otherwise don't. Don't truncate by
|
|
231
|
+
--- default.
|
|
232
|
+
---
|
|
233
|
+
--- Use this to manually decide if section needs truncation or not.
|
|
234
|
+
---
|
|
235
|
+
---@param trunc_width number|nil Truncation width. If `nil`, output is `false`.
|
|
236
|
+
---
|
|
237
|
+
---@return boolean Whether to truncate.
|
|
238
|
+
MiniStatusline.is_truncated = function(trunc_width)
|
|
239
|
+
-- Use -1 to default to 'not truncated'
|
|
240
|
+
local cur_width = vim.o.laststatus == 3 and vim.o.columns or vim.api.nvim_win_get_width(0)
|
|
241
|
+
return cur_width < (trunc_width or -1)
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
-- Sections ===================================================================
|
|
245
|
+
-- Functions should return output text without whitespace on sides.
|
|
246
|
+
-- Return empty string to omit section.
|
|
247
|
+
|
|
248
|
+
--- Section for Vim |mode()|
|
|
249
|
+
---
|
|
250
|
+
--- Short output is returned if window width is lower than `args.trunc_width`.
|
|
251
|
+
---
|
|
252
|
+
---@param args __statusline_args
|
|
253
|
+
---
|
|
254
|
+
---@return ... Section string and mode's highlight group.
|
|
255
|
+
MiniStatusline.section_mode = function(args)
|
|
256
|
+
local mode_info = H.modes[vim.fn.mode()]
|
|
257
|
+
|
|
258
|
+
local mode = MiniStatusline.is_truncated(args.trunc_width) and mode_info.short or mode_info.long
|
|
259
|
+
|
|
260
|
+
return mode, mode_info.hl
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
--- Section for Git information
|
|
264
|
+
---
|
|
265
|
+
--- Shows Git summary from |mini.git| (should be set up; recommended). To tweak
|
|
266
|
+
--- formatting of what data is shown, modify buffer-local summary string directly
|
|
267
|
+
--- as described in |MiniGit-examples|.
|
|
268
|
+
---
|
|
269
|
+
--- If |mini.git| is not set up, section falls back on `lewis6991/gitsigns.nvim` data
|
|
270
|
+
--- or showing empty string.
|
|
271
|
+
---
|
|
272
|
+
--- Empty string is returned if window width is lower than `args.trunc_width`.
|
|
273
|
+
---
|
|
274
|
+
---@param args __statusline_args Use `args.icon` to supply your own icon.
|
|
275
|
+
---
|
|
276
|
+
---@return __statusline_section
|
|
277
|
+
MiniStatusline.section_git = function(args)
|
|
278
|
+
if MiniStatusline.is_truncated(args.trunc_width) then return '' end
|
|
279
|
+
|
|
280
|
+
local summary = vim.b.minigit_summary_string or vim.b.gitsigns_head
|
|
281
|
+
if summary == nil then return '' end
|
|
282
|
+
|
|
283
|
+
local use_icons = H.use_icons or H.get_config().use_icons
|
|
284
|
+
local icon = args.icon or (use_icons and '' or 'Git')
|
|
285
|
+
return icon .. ' ' .. (summary == '' and '-' or summary)
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
--- Section for diff information
|
|
289
|
+
---
|
|
290
|
+
--- Shows diff summary from |mini.diff| (should be set up; recommended). To tweak
|
|
291
|
+
--- formatting of what data is shown, modify buffer-local summary string directly
|
|
292
|
+
--- as described in |MiniDiff-diff-summary|.
|
|
293
|
+
---
|
|
294
|
+
--- If |mini.diff| is not set up, section falls back on `lewis6991/gitsigns.nvim` data
|
|
295
|
+
--- or showing empty string.
|
|
296
|
+
---
|
|
297
|
+
--- Empty string is returned if window width is lower than `args.trunc_width`.
|
|
298
|
+
---
|
|
299
|
+
---@param args __statusline_args Use `args.icon` to supply your own icon.
|
|
300
|
+
---
|
|
301
|
+
---@return __statusline_section
|
|
302
|
+
MiniStatusline.section_diff = function(args)
|
|
303
|
+
if MiniStatusline.is_truncated(args.trunc_width) then return '' end
|
|
304
|
+
|
|
305
|
+
local summary = vim.b.minidiff_summary_string or vim.b.gitsigns_status
|
|
306
|
+
if summary == nil then return '' end
|
|
307
|
+
|
|
308
|
+
local use_icons = H.use_icons or H.get_config().use_icons
|
|
309
|
+
local icon = args.icon or (use_icons and '' or 'Diff')
|
|
310
|
+
return icon .. ' ' .. (summary == '' and '-' or summary)
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
--- Section for Neovim's builtin diagnostics
|
|
314
|
+
---
|
|
315
|
+
--- Shows nothing if diagnostics is disabled, no diagnostic is set, or for short
|
|
316
|
+
--- output. Otherwise uses |vim.diagnostic.get()| to compute and show number of
|
|
317
|
+
--- errors (`E`), warnings (`W`), information (`I`), and hints (`H`).
|
|
318
|
+
---
|
|
319
|
+
--- Short output is returned if window width is lower than `args.trunc_width`.
|
|
320
|
+
---
|
|
321
|
+
---@param args __statusline_args Use `args.icon` to supply your own icon.
|
|
322
|
+
--- Use `args.signs` to use custom signs per severity level name. For example: >lua
|
|
323
|
+
---
|
|
324
|
+
--- { ERROR = '!', WARN = '?', INFO = '@', HINT = '*' }
|
|
325
|
+
--- <
|
|
326
|
+
---@return __statusline_section
|
|
327
|
+
MiniStatusline.section_diagnostics = function(args)
|
|
328
|
+
if MiniStatusline.is_truncated(args.trunc_width) then return '' end
|
|
329
|
+
|
|
330
|
+
-- Construct string parts. NOTE: call `diagnostic_is_disabled()` *after*
|
|
331
|
+
-- check for present `count` to not source `vim.diagnostic` on startup.
|
|
332
|
+
local count = H.diagnostic_counts[vim.api.nvim_get_current_buf()]
|
|
333
|
+
if count == nil or H.diagnostic_is_disabled() then return '' end
|
|
334
|
+
|
|
335
|
+
local severity, signs, t = vim.diagnostic.severity, args.signs or {}, {}
|
|
336
|
+
for _, level in ipairs(H.diagnostic_levels) do
|
|
337
|
+
local n = count[severity[level.name]] or 0
|
|
338
|
+
-- Add level info only if diagnostic is present
|
|
339
|
+
if n > 0 then table.insert(t, ' ' .. (signs[level.name] or level.sign) .. n) end
|
|
340
|
+
end
|
|
341
|
+
if #t == 0 then return '' end
|
|
342
|
+
|
|
343
|
+
local use_icons = H.use_icons or H.get_config().use_icons
|
|
344
|
+
local icon = args.icon or (use_icons and '' or 'Diag')
|
|
345
|
+
return icon .. table.concat(t, '')
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
--- Section for attached LSP servers
|
|
349
|
+
---
|
|
350
|
+
--- Shows number of LSP servers (each as separate "+" character) attached to
|
|
351
|
+
--- current buffer or nothing if none is attached.
|
|
352
|
+
--- Nothing is shown if window width is lower than `args.trunc_width`.
|
|
353
|
+
---
|
|
354
|
+
---@param args __statusline_args Use `args.icon` to supply your own icon.
|
|
355
|
+
---
|
|
356
|
+
---@return __statusline_section
|
|
357
|
+
MiniStatusline.section_lsp = function(args)
|
|
358
|
+
if MiniStatusline.is_truncated(args.trunc_width) then return '' end
|
|
359
|
+
|
|
360
|
+
local attached = H.attached_lsp[vim.api.nvim_get_current_buf()] or ''
|
|
361
|
+
if attached == '' then return '' end
|
|
362
|
+
|
|
363
|
+
local use_icons = H.use_icons or H.get_config().use_icons
|
|
364
|
+
local icon = args.icon or (use_icons and '' or 'LSP')
|
|
365
|
+
return icon .. ' ' .. attached
|
|
366
|
+
end
|
|
367
|
+
|
|
368
|
+
--- Section for file name
|
|
369
|
+
---
|
|
370
|
+
--- Show full file name or relative in short output.
|
|
371
|
+
---
|
|
372
|
+
--- Short output is returned if window width is lower than `args.trunc_width`.
|
|
373
|
+
---
|
|
374
|
+
---@param args __statusline_args
|
|
375
|
+
---
|
|
376
|
+
---@return __statusline_section
|
|
377
|
+
MiniStatusline.section_filename = function(args)
|
|
378
|
+
-- In terminal always use plain name
|
|
379
|
+
if vim.bo.buftype == 'terminal' then
|
|
380
|
+
return '%t'
|
|
381
|
+
elseif MiniStatusline.is_truncated(args.trunc_width) then
|
|
382
|
+
-- File name with 'truncate', 'modified', 'readonly' flags
|
|
383
|
+
-- Use relative path if truncated
|
|
384
|
+
return '%f%m%r'
|
|
385
|
+
else
|
|
386
|
+
-- Use fullpath if not truncated
|
|
387
|
+
return '%F%m%r'
|
|
388
|
+
end
|
|
389
|
+
end
|
|
390
|
+
|
|
391
|
+
--- Section for file information
|
|
392
|
+
---
|
|
393
|
+
--- Shows |'filetype'|, |'fileencoding'| / |'encoding'|, |'fileformat'|, and buffer size.
|
|
394
|
+
--- Short output has only non-empty |'filetype'| and is returned if window width is
|
|
395
|
+
--- lower than `args.trunc_width` or buffer is not normal (as per |'buftype'|).
|
|
396
|
+
---
|
|
397
|
+
--- Buffer size is computed based on current text, not file's saved version.
|
|
398
|
+
---
|
|
399
|
+
--- If `config.use_icons` is true and icon provider is present (see
|
|
400
|
+
--- "Dependencies" section in |mini.statusline|), shows icon near the filetype.
|
|
401
|
+
---
|
|
402
|
+
---@param args __statusline_args
|
|
403
|
+
---
|
|
404
|
+
---@return __statusline_section
|
|
405
|
+
MiniStatusline.section_fileinfo = function(args)
|
|
406
|
+
local filetype = vim.bo.filetype
|
|
407
|
+
|
|
408
|
+
-- Add filetype icon
|
|
409
|
+
H.ensure_get_icon()
|
|
410
|
+
if H.get_icon ~= nil and filetype ~= '' then filetype = H.get_icon(filetype) .. ' ' .. filetype end
|
|
411
|
+
|
|
412
|
+
-- Construct output string if truncated or buffer is not normal
|
|
413
|
+
if MiniStatusline.is_truncated(args.trunc_width) or vim.bo.buftype ~= '' then return filetype end
|
|
414
|
+
|
|
415
|
+
-- Construct output string with extra file info
|
|
416
|
+
local encoding = vim.bo.fileencoding or vim.bo.encoding
|
|
417
|
+
local format = vim.bo.fileformat
|
|
418
|
+
local size = H.get_filesize()
|
|
419
|
+
|
|
420
|
+
return string.format('%s%s%s[%s] %s', filetype, filetype == '' and '' or ' ', encoding, format, size)
|
|
421
|
+
end
|
|
422
|
+
|
|
423
|
+
--- Section for location inside buffer
|
|
424
|
+
---
|
|
425
|
+
--- Show location inside buffer in the form:
|
|
426
|
+
--- - Normal: `'<cursor line>|<total lines>│<cursor column>|<total columns>'`
|
|
427
|
+
--- - Short: `'<cursor line>│<cursor column>'`
|
|
428
|
+
---
|
|
429
|
+
--- Short output is returned if window width is lower than `args.trunc_width`.
|
|
430
|
+
---
|
|
431
|
+
---@param args __statusline_args
|
|
432
|
+
---
|
|
433
|
+
---@return __statusline_section
|
|
434
|
+
MiniStatusline.section_location = function(args)
|
|
435
|
+
-- Use virtual column number to allow update when past last column
|
|
436
|
+
if MiniStatusline.is_truncated(args.trunc_width) then return '%l│%2v' end
|
|
437
|
+
|
|
438
|
+
-- Use `virtcol()` to correctly handle multi-byte characters
|
|
439
|
+
return '%l|%L│%2v|%-2{virtcol("$") - 1}'
|
|
440
|
+
end
|
|
441
|
+
|
|
442
|
+
--- Section for current search count
|
|
443
|
+
---
|
|
444
|
+
--- Show the current status of |searchcount()|. Empty output is returned if
|
|
445
|
+
--- window width is lower than `args.trunc_width`, search highlighting is not
|
|
446
|
+
--- on (see |v:hlsearch|), or if number of search result is 0.
|
|
447
|
+
---
|
|
448
|
+
--- `args.options` is forwarded to |searchcount()|. By default it recomputes
|
|
449
|
+
--- data on every call which can be computationally expensive (although still
|
|
450
|
+
--- usually on 0.1 ms order of magnitude). To prevent this, supply
|
|
451
|
+
--- `args.options = { recompute = false }`.
|
|
452
|
+
---
|
|
453
|
+
---@param args __statusline_args
|
|
454
|
+
---
|
|
455
|
+
---@return __statusline_section
|
|
456
|
+
MiniStatusline.section_searchcount = function(args)
|
|
457
|
+
if vim.v.hlsearch == 0 or MiniStatusline.is_truncated(args.trunc_width) then return '' end
|
|
458
|
+
-- `searchcount()` can return errors because it is evaluated very often in
|
|
459
|
+
-- statusline. For example, when typing `/` followed by `\(`, it gives E54.
|
|
460
|
+
local ok, s_count = pcall(vim.fn.searchcount, (args or {}).options or { recompute = true })
|
|
461
|
+
if not ok or s_count.current == nil or s_count.total == 0 then return '' end
|
|
462
|
+
|
|
463
|
+
if s_count.incomplete == 1 then return '?/?' end
|
|
464
|
+
|
|
465
|
+
local too_many = '>' .. s_count.maxcount
|
|
466
|
+
local current = s_count.current > s_count.maxcount and too_many or s_count.current
|
|
467
|
+
local total = s_count.total > s_count.maxcount and too_many or s_count.total
|
|
468
|
+
return current .. '/' .. total
|
|
469
|
+
end
|
|
470
|
+
|
|
471
|
+
-- Helper data ================================================================
|
|
472
|
+
-- Module default config
|
|
473
|
+
H.default_config = vim.deepcopy(MiniStatusline.config)
|
|
474
|
+
|
|
475
|
+
-- Showed diagnostic levels
|
|
476
|
+
H.diagnostic_levels = {
|
|
477
|
+
{ name = 'ERROR', sign = 'E' },
|
|
478
|
+
{ name = 'WARN', sign = 'W' },
|
|
479
|
+
{ name = 'INFO', sign = 'I' },
|
|
480
|
+
{ name = 'HINT', sign = 'H' },
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
-- Diagnostic counts per buffer id
|
|
484
|
+
H.diagnostic_counts = {}
|
|
485
|
+
|
|
486
|
+
-- String representation of attached LSP clients per buffer id
|
|
487
|
+
H.attached_lsp = {}
|
|
488
|
+
|
|
489
|
+
-- Helper functionality =======================================================
|
|
490
|
+
-- Settings -------------------------------------------------------------------
|
|
491
|
+
H.setup_config = function(config)
|
|
492
|
+
H.check_type('config', config, 'table', true)
|
|
493
|
+
config = vim.tbl_deep_extend('force', vim.deepcopy(H.default_config), config or {})
|
|
494
|
+
|
|
495
|
+
H.check_type('content', config.content, 'table')
|
|
496
|
+
H.check_type('content.active', config.content.active, 'function', true)
|
|
497
|
+
H.check_type('content.inactive', config.content.inactive, 'function', true)
|
|
498
|
+
|
|
499
|
+
H.check_type('use_icons', config.use_icons, 'boolean')
|
|
500
|
+
|
|
501
|
+
return config
|
|
502
|
+
end
|
|
503
|
+
|
|
504
|
+
H.apply_config = function(config)
|
|
505
|
+
MiniStatusline.config = config
|
|
506
|
+
|
|
507
|
+
-- Set statusline globally and dynamically decide which content to use
|
|
508
|
+
vim.go.statusline =
|
|
509
|
+
'%{%(nvim_get_current_win()==#g:actual_curwin || &laststatus==3) ? v:lua.MiniStatusline.active() : v:lua.MiniStatusline.inactive()%}'
|
|
510
|
+
end
|
|
511
|
+
|
|
512
|
+
H.create_autocommands = function()
|
|
513
|
+
local gr = vim.api.nvim_create_augroup('MiniStatusline', {})
|
|
514
|
+
|
|
515
|
+
local au = function(event, pattern, callback, desc)
|
|
516
|
+
vim.api.nvim_create_autocmd(event, { group = gr, pattern = pattern, callback = callback, desc = desc })
|
|
517
|
+
end
|
|
518
|
+
|
|
519
|
+
-- Use `schedule_wrap()` because at `LspDetach` server is still present
|
|
520
|
+
local track_lsp = vim.schedule_wrap(function(data)
|
|
521
|
+
H.attached_lsp[data.buf] = vim.api.nvim_buf_is_valid(data.buf) and H.compute_attached_lsp(data.buf) or nil
|
|
522
|
+
vim.cmd('redrawstatus')
|
|
523
|
+
end)
|
|
524
|
+
au({ 'LspAttach', 'LspDetach' }, '*', track_lsp, 'Track LSP clients')
|
|
525
|
+
|
|
526
|
+
-- Use `schedule_wrap()` because `redrawstatus` might error on `:bwipeout`
|
|
527
|
+
-- See: https://github.com/neovim/neovim/issues/32349
|
|
528
|
+
local track_diagnostics = vim.schedule_wrap(function(data)
|
|
529
|
+
H.diagnostic_counts[data.buf] = vim.api.nvim_buf_is_valid(data.buf) and H.get_diagnostic_count(data.buf) or nil
|
|
530
|
+
vim.cmd('redrawstatus')
|
|
531
|
+
end)
|
|
532
|
+
au('DiagnosticChanged', '*', track_diagnostics, 'Track diagnostics')
|
|
533
|
+
|
|
534
|
+
au('ColorScheme', '*', H.create_default_hl, 'Ensure colors')
|
|
535
|
+
end
|
|
536
|
+
|
|
537
|
+
--stylua: ignore
|
|
538
|
+
H.create_default_hl = function()
|
|
539
|
+
local set_default_hl = function(name, data)
|
|
540
|
+
data.default = true
|
|
541
|
+
vim.api.nvim_set_hl(0, name, data)
|
|
542
|
+
end
|
|
543
|
+
|
|
544
|
+
set_default_hl('MiniStatuslineModeNormal', { link = 'Cursor' })
|
|
545
|
+
set_default_hl('MiniStatuslineModeInsert', { link = 'DiffChange' })
|
|
546
|
+
set_default_hl('MiniStatuslineModeVisual', { link = 'DiffAdd' })
|
|
547
|
+
set_default_hl('MiniStatuslineModeReplace', { link = 'DiffDelete' })
|
|
548
|
+
set_default_hl('MiniStatuslineModeCommand', { link = 'DiffText' })
|
|
549
|
+
set_default_hl('MiniStatuslineModeOther', { link = 'IncSearch' })
|
|
550
|
+
|
|
551
|
+
set_default_hl('MiniStatuslineDevinfo', { link = 'StatusLine' })
|
|
552
|
+
set_default_hl('MiniStatuslineFilename', { link = 'StatusLineNC' })
|
|
553
|
+
set_default_hl('MiniStatuslineFileinfo', { link = 'StatusLine' })
|
|
554
|
+
set_default_hl('MiniStatuslineInactive', { link = 'StatusLineNC' })
|
|
555
|
+
end
|
|
556
|
+
|
|
557
|
+
H.is_disabled = function() return vim.g.ministatusline_disable == true or vim.b.ministatusline_disable == true end
|
|
558
|
+
|
|
559
|
+
H.get_config = function(config)
|
|
560
|
+
return vim.tbl_deep_extend('force', MiniStatusline.config, vim.b.ministatusline_config or {}, config or {})
|
|
561
|
+
end
|
|
562
|
+
|
|
563
|
+
-- Mode -----------------------------------------------------------------------
|
|
564
|
+
-- Custom `^V` and `^S` symbols to make this file appropriate for copy-paste
|
|
565
|
+
-- (otherwise those symbols are not displayed).
|
|
566
|
+
local CTRL_S = vim.api.nvim_replace_termcodes('<C-S>', true, true, true)
|
|
567
|
+
local CTRL_V = vim.api.nvim_replace_termcodes('<C-V>', true, true, true)
|
|
568
|
+
|
|
569
|
+
-- stylua: ignore start
|
|
570
|
+
H.modes = setmetatable({
|
|
571
|
+
['n'] = { long = 'Normal', short = 'N', hl = 'MiniStatuslineModeNormal' },
|
|
572
|
+
['v'] = { long = 'Visual', short = 'V', hl = 'MiniStatuslineModeVisual' },
|
|
573
|
+
['V'] = { long = 'V-Line', short = 'V-L', hl = 'MiniStatuslineModeVisual' },
|
|
574
|
+
[CTRL_V] = { long = 'V-Block', short = 'V-B', hl = 'MiniStatuslineModeVisual' },
|
|
575
|
+
['s'] = { long = 'Select', short = 'S', hl = 'MiniStatuslineModeVisual' },
|
|
576
|
+
['S'] = { long = 'S-Line', short = 'S-L', hl = 'MiniStatuslineModeVisual' },
|
|
577
|
+
[CTRL_S] = { long = 'S-Block', short = 'S-B', hl = 'MiniStatuslineModeVisual' },
|
|
578
|
+
['i'] = { long = 'Insert', short = 'I', hl = 'MiniStatuslineModeInsert' },
|
|
579
|
+
['R'] = { long = 'Replace', short = 'R', hl = 'MiniStatuslineModeReplace' },
|
|
580
|
+
['c'] = { long = 'Command', short = 'C', hl = 'MiniStatuslineModeCommand' },
|
|
581
|
+
['r'] = { long = 'Prompt', short = 'P', hl = 'MiniStatuslineModeOther' },
|
|
582
|
+
['!'] = { long = 'Shell', short = 'Sh', hl = 'MiniStatuslineModeOther' },
|
|
583
|
+
['t'] = { long = 'Terminal', short = 'T', hl = 'MiniStatuslineModeOther' },
|
|
584
|
+
}, {
|
|
585
|
+
-- By default return 'Unknown' but this shouldn't be needed
|
|
586
|
+
__index = function()
|
|
587
|
+
return { long = 'Unknown', short = 'U', hl = '%#MiniStatuslineModeOther#' }
|
|
588
|
+
end,
|
|
589
|
+
})
|
|
590
|
+
-- stylua: ignore end
|
|
591
|
+
|
|
592
|
+
-- Default content ------------------------------------------------------------
|
|
593
|
+
--stylua: ignore
|
|
594
|
+
H.default_content_active = function()
|
|
595
|
+
H.use_icons = H.get_config().use_icons
|
|
596
|
+
local mode, mode_hl = MiniStatusline.section_mode({ trunc_width = 120 })
|
|
597
|
+
local git = MiniStatusline.section_git({ trunc_width = 40 })
|
|
598
|
+
local diff = MiniStatusline.section_diff({ trunc_width = 75 })
|
|
599
|
+
local diagnostics = MiniStatusline.section_diagnostics({ trunc_width = 75 })
|
|
600
|
+
local lsp = MiniStatusline.section_lsp({ trunc_width = 75 })
|
|
601
|
+
local filename = MiniStatusline.section_filename({ trunc_width = 140 })
|
|
602
|
+
local fileinfo = MiniStatusline.section_fileinfo({ trunc_width = 120 })
|
|
603
|
+
local location = MiniStatusline.section_location({ trunc_width = 75 })
|
|
604
|
+
local search = MiniStatusline.section_searchcount({ trunc_width = 75 })
|
|
605
|
+
H.use_icons = nil
|
|
606
|
+
|
|
607
|
+
-- Usage of `MiniStatusline.combine_groups()` ensures highlighting and
|
|
608
|
+
-- correct padding with spaces between groups (accounts for 'missing'
|
|
609
|
+
-- sections, etc.)
|
|
610
|
+
return MiniStatusline.combine_groups({
|
|
611
|
+
{ hl = mode_hl, strings = { mode } },
|
|
612
|
+
{ hl = 'MiniStatuslineDevinfo', strings = { git, diff, diagnostics, lsp } },
|
|
613
|
+
'%<', -- Mark general truncate point
|
|
614
|
+
{ hl = 'MiniStatuslineFilename', strings = { filename } },
|
|
615
|
+
'%=', -- End left alignment
|
|
616
|
+
{ hl = 'MiniStatuslineFileinfo', strings = { fileinfo } },
|
|
617
|
+
{ hl = mode_hl, strings = { search, location } },
|
|
618
|
+
})
|
|
619
|
+
end
|
|
620
|
+
|
|
621
|
+
H.default_content_inactive = function() return '%#MiniStatuslineInactive#%F%=' end
|
|
622
|
+
|
|
623
|
+
-- LSP ------------------------------------------------------------------------
|
|
624
|
+
H.compute_attached_lsp = function(buf_id) return string.rep('+', vim.tbl_count(H.get_buf_lsp_clients(buf_id))) end
|
|
625
|
+
|
|
626
|
+
H.get_buf_lsp_clients = function(buf_id) return vim.lsp.get_clients({ bufnr = buf_id }) end
|
|
627
|
+
-- NOTE: Use `has('nvim-0.xx')` instead of directly checking presence of target
|
|
628
|
+
-- function to avoid loading `vim.xxx` modules at `require('mini.statusline')`.
|
|
629
|
+
-- This visibly improves startup time.
|
|
630
|
+
if vim.fn.has('nvim-0.10') == 0 then
|
|
631
|
+
H.get_buf_lsp_clients = function(buf_id) return vim.lsp.buf_get_clients(buf_id) end
|
|
632
|
+
end
|
|
633
|
+
|
|
634
|
+
-- Diagnostics ----------------------------------------------------------------
|
|
635
|
+
H.get_diagnostic_count = function(buf_id) return vim.diagnostic.count(buf_id) end
|
|
636
|
+
if vim.fn.has('nvim-0.10') == 0 then
|
|
637
|
+
H.get_diagnostic_count = function(buf_id)
|
|
638
|
+
local res = {}
|
|
639
|
+
for _, d in ipairs(vim.diagnostic.get(buf_id)) do
|
|
640
|
+
res[d.severity] = (res[d.severity] or 0) + 1
|
|
641
|
+
end
|
|
642
|
+
return res
|
|
643
|
+
end
|
|
644
|
+
end
|
|
645
|
+
|
|
646
|
+
H.diagnostic_is_disabled = function() return not vim.diagnostic.is_enabled({ bufnr = 0 }) end
|
|
647
|
+
if vim.fn.has('nvim-0.10') == 0 then H.diagnostic_is_disabled = function() return vim.diagnostic.is_disabled(0) end end
|
|
648
|
+
|
|
649
|
+
-- Utilities ------------------------------------------------------------------
|
|
650
|
+
H.error = function(msg) error('(mini.statusline) ' .. msg, 0) end
|
|
651
|
+
|
|
652
|
+
H.check_type = function(name, val, ref, allow_nil)
|
|
653
|
+
if type(val) == ref or (ref == 'callable' and vim.is_callable(val)) or (allow_nil and val == nil) then return end
|
|
654
|
+
H.error(string.format('`%s` should be %s, not %s', name, ref, type(val)))
|
|
655
|
+
end
|
|
656
|
+
|
|
657
|
+
H.get_filesize = function()
|
|
658
|
+
local size = math.max(vim.fn.line2byte(vim.fn.line('$') + 1) - 1, 0)
|
|
659
|
+
if size < 1024 then
|
|
660
|
+
return string.format('%dB', size)
|
|
661
|
+
elseif size < 1048576 then
|
|
662
|
+
return string.format('%.2fKiB', size / 1024)
|
|
663
|
+
else
|
|
664
|
+
return string.format('%.2fMiB', size / 1048576)
|
|
665
|
+
end
|
|
666
|
+
end
|
|
667
|
+
|
|
668
|
+
H.ensure_get_icon = function()
|
|
669
|
+
if not (H.use_icons or H.get_config().use_icons) then
|
|
670
|
+
-- Show no icon
|
|
671
|
+
H.get_icon = nil
|
|
672
|
+
elseif H.get_icon ~= nil then
|
|
673
|
+
-- Cache only once
|
|
674
|
+
return
|
|
675
|
+
elseif _G.MiniIcons ~= nil then
|
|
676
|
+
-- Prefer 'mini.icons'
|
|
677
|
+
H.get_icon = function(filetype) return (_G.MiniIcons.get('filetype', filetype)) end
|
|
678
|
+
else
|
|
679
|
+
-- Try falling back to 'nvim-web-devicons'
|
|
680
|
+
local has_devicons, devicons = pcall(require, 'nvim-web-devicons')
|
|
681
|
+
if not has_devicons then return end
|
|
682
|
+
H.get_icon = function() return (devicons.get_icon(vim.fn.expand('%:t'), nil, { default = true })) end
|
|
683
|
+
end
|
|
684
|
+
end
|
|
685
|
+
|
|
686
|
+
return MiniStatusline
|