diff --git a/.config/nvim/lua/plugin/mini.lua b/.config/nvim/lua/plugin/mini.lua index 99e26e9..91dc122 100644 --- a/.config/nvim/lua/plugin/mini.lua +++ b/.config/nvim/lua/plugin/mini.lua @@ -85,16 +85,43 @@ MiniDeps.later(function() end) -- TODO: show history 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('', true, true, true) +local CTRL_V = vim.api.nvim_replace_termcodes('', 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({ content = { active = function() - local mode, mode_hl = MiniStatusline.section_mode({ trunc_width = 120 }) - local git = MiniStatusline.section_git({ trunc_width = 40 }) - local diff = MiniStatusline.section_diff({ trunc_width = 75 }) - local diagnostics = MiniStatusline.section_diagnostics({ trunc_width = 75 }) - local lsp = MiniStatusline.section_lsp({ trunc_width = 75 }) - local filename = MiniStatusline.section_filename({ trunc_width = 140 }) - local fileinfo = MiniStatusline.section_fileinfo({ 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 diff = MiniStatusline.section_diff({ trunc_width = 75 }) + local diagnostics = MiniStatusline.section_diagnostics({ trunc_width = 75 }) + local lsp = MiniStatusline.section_lsp({ trunc_width = 75 }) + local filename = MiniStatusline.section_filename({ trunc_width = 140 }) + local fileinfo = MiniStatusline.section_fileinfo({ trunc_width = 120 }) return MiniStatusline.combine_groups({ { hl = mode_hl, strings = { mode } },