| 1 |
-- Copyright (c) 2020-2021 hoob3rt |
| 2 |
-- MIT license, see LICENSE for more details. |
| 3 |
local Mode = {} |
| 4 |
|
| 5 |
-- stylua: ignore |
| 6 |
Mode.map = { |
| 7 |
['n'] = 'NORMAL', |
| 8 |
['no'] = 'O-PENDING', |
| 9 |
['nov'] = 'O-PENDING', |
| 10 |
['noV'] = 'O-PENDING', |
| 11 |
['no\22'] = 'O-PENDING', |
| 12 |
['niI'] = 'NORMAL', |
| 13 |
['niR'] = 'NORMAL', |
| 14 |
['niV'] = 'NORMAL', |
| 15 |
['nt'] = 'NORMAL', |
| 16 |
['ntT'] = 'NORMAL', |
| 17 |
['v'] = 'VISUAL', |
| 18 |
['vs'] = 'VISUAL', |
| 19 |
['V'] = 'V-LINE', |
| 20 |
['Vs'] = 'V-LINE', |
| 21 |
['\22'] = 'V-BLOCK', |
| 22 |
['\22s'] = 'V-BLOCK', |
| 23 |
['s'] = 'SELECT', |
| 24 |
['S'] = 'S-LINE', |
| 25 |
['\19'] = 'S-BLOCK', |
| 26 |
['i'] = 'INSERT', |
| 27 |
['ic'] = 'INSERT', |
| 28 |
['ix'] = 'INSERT', |
| 29 |
['R'] = 'REPLACE', |
| 30 |
['Rc'] = 'REPLACE', |
| 31 |
['Rx'] = 'REPLACE', |
| 32 |
['Rv'] = 'V-REPLACE', |
| 33 |
['Rvc'] = 'V-REPLACE', |
| 34 |
['Rvx'] = 'V-REPLACE', |
| 35 |
['c'] = 'COMMAND', |
| 36 |
['cv'] = 'EX', |
| 37 |
['ce'] = 'EX', |
| 38 |
['r'] = 'REPLACE', |
| 39 |
['rm'] = 'MORE', |
| 40 |
['r?'] = 'CONFIRM', |
| 41 |
['!'] = 'SHELL', |
| 42 |
['t'] = 'TERMINAL', |
| 43 |
} |
| 44 |
|
| 45 |
---@return string current mode name |
| 46 |
function Mode.get_mode() |
| 47 |
local mode_code = vim.api.nvim_get_mode().mode |
| 48 |
if Mode.map[mode_code] == nil then |
| 49 |
return mode_code |
| 50 |
end |
| 51 |
return Mode.map[mode_code] |
| 52 |
end |
| 53 |
|
| 54 |
return Mode |