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,4 +1,5 @@
local config = function() local config = function()
local get_mode_icon = function()
local MODES = { local MODES = {
['n'] = '', -- 'Normal ', -- Normal ['n'] = '', -- 'Normal ', -- Normal
['no'] = '', -- 'O-Pend ', -- Operator-pending ['no'] = '', -- 'O-Pend ', -- Operator-pending
@ -17,6 +18,11 @@ local config = function()
['!'] = '', -- ' Shell ', -- External command executing ['!'] = '', -- ' Shell ', -- External command executing
['t'] = '', -- ' Term ', -- Terminal ['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)