Restructure mode conponent

This commit is contained in:
shadmansaleh 2021-03-14 20:14:19 +06:00
parent b79fd4cc24
commit daa4cd45b3
1 changed files with 34 additions and 37 deletions

View File

@ -1,44 +1,41 @@
-- Copyright (c) 2020-2021 hoob3rt -- Copyright (c) 2020-2021 hoob3rt
-- MIT license, see LICENSE for more details. -- MIT license, see LICENSE for more details.
local mode_map = {
['n'] = 'NORMAL',
['no'] = 'O-PENDING',
['nov'] = 'O-PENDING',
['noV'] = 'O-PENDING',
['no'] = 'O-PENDING',
['niI'] = 'NORMAL',
['niR'] = 'NORMAL',
['niV'] = 'NORMAL',
['v'] = 'VISUAL',
['V'] = 'V-LINE',
[''] = 'V-BLOCK',
['s'] = 'SELECT',
['S'] = 'S-LINE',
[''] = 'S-BLOCK',
['i'] = 'INSERT',
['ic'] = 'INSERT',
['ix'] = 'INSERT',
['R'] = 'REPLACE',
['Rc'] = 'REPLACE',
['Rv'] = 'V-REPLACE',
['Rx'] = 'REPLACE',
['c'] = 'COMMAND',
['cv'] = 'EX',
['ce'] = 'EX',
['r'] = 'REPLACE',
['rm'] = 'MORE',
['r?'] = 'CONFIRM',
['!'] = 'SHELL',
['t'] = 'TERMINAL',
}
local function mode() local function mode()
local mode_map = { local mode_code = vim.api.nvim_get_mode().mode
['n'] = 'NORMAL', if mode_map[mode_code] == nil then return mode_code end
['no'] = 'O-PENDING', return mode_map[mode_code]
['nov'] = 'O-PENDING',
['noV'] = 'O-PENDING',
['no'] = 'O-PENDING',
['niI'] = 'NORMAL',
['niR'] = 'NORMAL',
['niV'] = 'NORMAL',
['v'] = 'VISUAL',
['V'] = 'V-LINE',
[''] = 'V-BLOCK',
['s'] = 'SELECT',
['S'] = 'S-LINE',
[''] = 'S-BLOCK',
['i'] = 'INSERT',
['ic'] = 'INSERT',
['ix'] = 'INSERT',
['R'] = 'REPLACE',
['Rc'] = 'REPLACE',
['Rv'] = 'V-REPLACE',
['Rx'] = 'REPLACE',
['c'] = 'COMMAND',
['cv'] = 'EX',
['ce'] = 'EX',
['r'] = 'REPLACE',
['rm'] = 'MORE',
['r?'] = 'CONFIRM',
['!'] = 'SHELL',
['t'] = 'TERMINAL',
}
local function get_mode()
local mode_code = vim.api.nvim_get_mode().mode
if mode_map[mode_code] == nil then return mode_code end
return mode_map[mode_code]
end
return get_mode()
end end
return mode return mode