modify mini statusline to use all-caps mode names.

This commit is contained in:
2025-12-12 12:47:56 +01:00
parent 42fba07935
commit d494670a8a

View File

@@ -85,10 +85,37 @@ MiniDeps.later(function()
end) end)
-- TODO: show history -- TODO: show history
require('mini.notify').setup() -- has more noticeable / utilitarian / aesthetically pleasing notifications require('mini.notify').setup() -- has more noticeable / utilitarian / aesthetically pleasing notifications
-- Custom `^V` and `^S` symbols to make this file appropriate for copy-paste
-- (otherwise those symbols are not displayed).
local CTRL_S = vim.api.nvim_replace_termcodes('<C-S>', true, true, true)
local CTRL_V = vim.api.nvim_replace_termcodes('<C-V>', true, true, true)
local modes = setmetatable({
['n'] = { long = 'NORMAL', short = 'N', hl = 'MiniStatuslineModeNormal' },
['v'] = { long = 'VISUAL', short = 'V', hl = 'MiniStatuslineModeVisual' },
['V'] = { long = 'V-LINE', short = 'V-L', hl = 'MiniStatuslineModeVisual' },
[CTRL_V] = { long = 'V-BLOCK', short = 'V-B', hl = 'MiniStatuslineModeVisual' },
['s'] = { long = 'SELECT', short = 'S', hl = 'MiniStatuslineModeVisual' },
['S'] = { long = 'S-LINE', short = 'S-L', hl = 'MiniStatuslineModeVisual' },
[CTRL_S] = { long = 'S-BLOCK', short = 'S-B', hl = 'MiniStatuslineModeVisual' },
['i'] = { long = 'INSERT', short = 'I', hl = 'MiniStatuslineModeInsert' },
['R'] = { long = 'REPLACE', short = 'R', hl = 'MiniStatuslineModeReplace' },
['c'] = { long = 'COMMAND', short = 'C', hl = 'MiniStatuslineModeCommand' },
['r'] = { long = 'PROMPT', short = 'P', hl = 'MiniStatuslineModeOther' },
['!'] = { long = 'SHELL', short = 'Sh', hl = 'MiniStatuslineModeOther' },
['t'] = { long = 'TERMINAL', short = 'T', hl = 'MiniStatuslineModeOther' },
}, {
-- By default return 'Unknown' but this shouldn't be needed
__index = function()
return { long = 'Unknown', short = 'U', hl = '%#MiniStatuslineModeOther#' }
end,
})
require('mini.statusline').setup({ require('mini.statusline').setup({
content = { content = {
active = function() active = function()
local mode, mode_hl = MiniStatusline.section_mode({ trunc_width = 120 }) local mode_info = modes[vim.fn.mode()]
local mode = MiniStatusline.is_truncated(120) and mode_info.short or mode_info.long
local mode_hl = mode_info.hl
local git = MiniStatusline.section_git({ trunc_width = 40 }) local git = MiniStatusline.section_git({ trunc_width = 40 })
local diff = MiniStatusline.section_diff({ trunc_width = 75 }) local diff = MiniStatusline.section_diff({ trunc_width = 75 })
local diagnostics = MiniStatusline.section_diagnostics({ trunc_width = 75 }) local diagnostics = MiniStatusline.section_diagnostics({ trunc_width = 75 })