2021-04-11 08:20:41 +00:00
|
|
|
-- Copyright (c) 2020-2021 hoob3rt
|
|
|
|
-- MIT license, see LICENSE for more details.
|
|
|
|
local Mode = {}
|
2021-10-12 14:04:47 +00:00
|
|
|
|
2021-09-03 18:20:34 +00:00
|
|
|
-- stylua: ignore
|
2021-04-11 08:20:41 +00:00
|
|
|
Mode.map = {
|
2022-04-24 05:29:53 +00:00
|
|
|
['n'] = 'NORMAL',
|
|
|
|
['no'] = 'O-PENDING',
|
|
|
|
['nov'] = 'O-PENDING',
|
|
|
|
['noV'] = 'O-PENDING',
|
2022-04-24 07:12:03 +00:00
|
|
|
['no\22'] = 'O-PENDING',
|
2022-04-24 05:29:53 +00:00
|
|
|
['niI'] = 'NORMAL',
|
|
|
|
['niR'] = 'NORMAL',
|
|
|
|
['niV'] = 'NORMAL',
|
|
|
|
['nt'] = 'NORMAL',
|
|
|
|
['v'] = 'VISUAL',
|
|
|
|
['vs'] = 'VISUAL',
|
|
|
|
['V'] = 'V-LINE',
|
|
|
|
['Vs'] = 'V-LINE',
|
2022-04-24 07:12:03 +00:00
|
|
|
['\22'] = 'V-BLOCK',
|
|
|
|
['\22s'] = 'V-BLOCK',
|
2022-04-24 05:29:53 +00:00
|
|
|
['s'] = 'SELECT',
|
|
|
|
['S'] = 'S-LINE',
|
2022-04-24 07:12:03 +00:00
|
|
|
['\19'] = 'S-BLOCK',
|
2022-04-24 05:29:53 +00:00
|
|
|
['i'] = 'INSERT',
|
|
|
|
['ic'] = 'INSERT',
|
|
|
|
['ix'] = 'INSERT',
|
|
|
|
['R'] = 'REPLACE',
|
|
|
|
['Rc'] = 'REPLACE',
|
|
|
|
['Rx'] = 'REPLACE',
|
|
|
|
['Rv'] = 'V-REPLACE',
|
|
|
|
['Rvc'] = 'V-REPLACE',
|
|
|
|
['Rvx'] = 'V-REPLACE',
|
|
|
|
['c'] = 'COMMAND',
|
|
|
|
['cv'] = 'EX',
|
|
|
|
['ce'] = 'EX',
|
|
|
|
['r'] = 'REPLACE',
|
|
|
|
['rm'] = 'MORE',
|
|
|
|
['r?'] = 'CONFIRM',
|
|
|
|
['!'] = 'SHELL',
|
|
|
|
['t'] = 'TERMINAL',
|
2021-04-11 08:20:41 +00:00
|
|
|
}
|
2021-09-03 18:20:34 +00:00
|
|
|
|
2021-10-12 14:04:47 +00:00
|
|
|
---@return string current mode name
|
2021-04-11 08:20:41 +00:00
|
|
|
function Mode.get_mode()
|
|
|
|
local mode_code = vim.api.nvim_get_mode().mode
|
2021-09-03 18:28:20 +00:00
|
|
|
if Mode.map[mode_code] == nil then
|
|
|
|
return mode_code
|
|
|
|
end
|
2021-04-11 08:20:41 +00:00
|
|
|
return Mode.map[mode_code]
|
|
|
|
end
|
|
|
|
|
|
|
|
return Mode
|