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 function mode()
local mode_map = { local mode_map = {
['__'] = '------', ['n'] = 'NORMAL',
['n'] = 'NORMAL', ['no'] = 'O-PENDING',
['i'] = 'INSERT', ['nov'] = 'O-PENDING',
['ic'] = 'INSERT', ['noV'] = 'O-PENDING',
['ix'] = 'INSERT', ['no'] = 'O-PENDING',
['v'] = 'VISUAL', ['niI'] = 'NORMAL',
['V'] = 'V-LINE', ['niR'] = 'NORMAL',
[''] = 'V-BLOCK', ['niV'] = 'NORMAL',
['R'] = 'REPLACE', ['v'] = 'VISUAL',
['r'] = 'REPLACE', ['V'] = 'V-LINE',
['rc'] = 'REPLACE', [''] = 'V-BLOCK',
['rx'] = 'REPLACE', ['s'] = 'SELECT',
['Rv'] = 'V-REPLACE', ['S'] = 'S-LINE',
['c'] = 'COMMAND', [''] = 'S-BLOCK',
['t'] = 'TERMINAL', ['i'] = 'INSERT',
['s'] = 'SELECT', ['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 function get_mode()
local mode_code = vim.api.nvim_get_mode().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 if not is_focused then
highlight_group = highlight_group .. [[_inactive]] highlight_group = highlight_group .. [[_inactive]]
else 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' 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' highlight_group = highlight_group .. '_replace'
elseif mode == 'INSERT' then elseif mode == 'INSERT' then
highlight_group = highlight_group .. '_insert' 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' highlight_group = highlight_group .. '_command'
elseif mode == 'TERMINAL' then elseif mode == 'TERMINAL' then
highlight_group = highlight_group .. '_terminal' highlight_group = highlight_group .. '_terminal'