vim/lualine: use icons for modes

This commit is contained in:
Fernando Schauenburg 2023-08-12 00:13:29 +02:00
parent 77c7c1a8b9
commit ecadf89867

View file

@ -1,22 +1,28 @@
local config = function() local config = function()
local MODES = { local get_mode_icon = function()
['n'] = '', -- 'Normal ', -- Normal local MODES = {
['no'] = '', -- 'O-Pend ', -- Operator-pending ['n'] = '', -- 'Normal ', -- Normal
['ni'] = '', -- 'Normal ', -- Normal via i_CTRL-O ['no'] = '', -- 'O-Pend ', -- Operator-pending
['v'] = ' 󰒉 ', -- 'Visual ', -- Visual by character ['ni'] = '', -- 'Normal ', -- Normal via i_CTRL-O
[''] = ' 󰩭 ', -- 'V-Block', -- Visual blockwise ['v'] = ' 󰒉 ', -- 'Visual ', -- Visual by character
['s'] = ' 󰒉 ', -- 'Select ', -- Select by character [''] = ' 󰩭 ', -- 'V-Block', -- Visual blockwise
[''] = ' 󰩭 ', -- 'S-Block', -- Select blockwise ['s'] = ' 󰒉 ', -- 'Select ', -- Select by character
['i'] = '', -- 'Insert ', -- Insert [''] = ' 󰩭 ', -- 'S-Block', -- Select blockwise
['r'] = ' 󰄾 ', -- 'Replace', -- Replace ['i'] = '', -- 'Insert ', -- Insert
['rv'] = ' 󰶻 ', -- 'V-Repl ', -- Virtual Replace ['r'] = ' 󰄾 ', -- 'Replace', -- Replace
['c'] = '', -- 'Command', -- Command-line ['rv'] = ' 󰶻 ', -- 'V-Repl ', -- Virtual Replace
['cv'] = '', -- ' Ex ', -- Ex mode ['c'] = '', -- 'Command', -- Command-line
['rm'] = '', -- ' More ', -- -- MORE -- ['cv'] = '', -- ' Ex ', -- Ex mode
['r?'] = ' 󰭚 ', -- 'Confirm', -- :confirm ['rm'] = '', -- ' More ', -- -- MORE --
['!'] = '', -- ' Shell ', -- External command executing ['r?'] = ' 󰭚 ', -- 'Confirm', -- :confirm
['t'] = '', -- ' Term ', -- Terminal ['!'] = '', -- ' Shell ', -- External command executing
} ['t'] = '', -- ' Term ', -- Terminal
}
return function()
local code = vim.api.nvim_get_mode().mode
return MODES[code:sub(1, 2):lower()] or MODES[code:sub(1, 1):lower()] or code
end
end
local extend = function(component, overrides) local extend = function(component, overrides)
local new = require(component):extend() local new = require(component):extend()
@ -47,12 +53,7 @@ local config = function()
diff = extend('lualine.components.diff', { update_status = udpate_with_color }), diff = extend('lualine.components.diff', { update_status = udpate_with_color }),
mode = { mode = { get_mode_icon() },
function()
local code = vim.api.nvim_get_mode().mode
return MODES[code:sub(1, 2):lower()] or MODES[code:sub(1, 1):lower()] or code
end,
},
visual_multi = function() visual_multi = function()
local info = vim.F.npcall(vim.fn.VMInfos) local info = vim.F.npcall(vim.fn.VMInfos)