Wider range of mode support (#57)

* Wider range of mode support

* Remove unnecessary entry in modes

Co-authored-by: hoob3rt <pelczarskihubert@gmail.com>
This commit is contained in:
Shadman 2021-01-11 09:52:34 +06:00 committed by GitHub
parent 8ff22c3935
commit 823665c511
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 19 deletions

View File

@ -1,21 +1,34 @@
local function mode()
local mode_map = {
['__'] = '------',
['n'] = 'NORMAL',
['i'] = 'INSERT',
['ic'] = 'INSERT',
['ix'] = 'INSERT',
['v'] = 'VISUAL',
['V'] = 'V-LINE',
[''] = 'V-BLOCK',
['R'] = 'REPLACE',
['r'] = 'REPLACE',
['rc'] = 'REPLACE',
['rx'] = 'REPLACE',
['Rv'] = 'V-REPLACE',
['c'] = 'COMMAND',
['t'] = 'TERMINAL',
['s'] = 'SELECT',
['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 get_mode()
local mode_code = vim.api.nvim_get_mode().mode

View File

@ -44,13 +44,14 @@ function M.format_highlight(is_focused, highlight_group)
if not is_focused then
highlight_group = highlight_group .. [[_inactive]]
else
if mode == 'VISUAL' or mode == 'V-BLOCK' or mode == 'V-LINE' or mode == 'SELECT' then
if mode == 'VISUAL' or mode == 'V-BLOCK' or mode == 'V-LINE'
or mode == 'SELECT' or mode == 'S-LINE' or mode == 'S-BLOCK'then
highlight_group = highlight_group .. '_visual'
elseif mode == 'V-REPLACE' or mode == 'REPLACE' then
elseif mode == 'REPLACE' or mode == 'V-REPLACE' then
highlight_group = highlight_group .. '_replace'
elseif mode == 'INSERT' then
highlight_group = highlight_group .. '_insert'
elseif mode == 'COMMAND' then
elseif mode == 'COMMAND' or mode == 'EX' or mode == 'MORE' or mode == 'CONFIRM'then
highlight_group = highlight_group .. '_command'
elseif mode == 'TERMINAL' then
highlight_group = highlight_group .. '_terminal'