From 823665c511d5727107a57e4f31205f92bb2c573e Mon Sep 17 00:00:00 2001 From: Shadman Date: Mon, 11 Jan 2021 09:52:34 +0600 Subject: [PATCH] Wider range of mode support (#57) * Wider range of mode support * Remove unnecessary entry in modes Co-authored-by: hoob3rt --- lua/lualine/components/mode.lua | 45 +++++++++++++++++++++------------ lua/lualine/highlight.lua | 7 ++--- 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/lua/lualine/components/mode.lua b/lua/lualine/components/mode.lua index d341f53..a177201 100644 --- a/lua/lualine/components/mode.lua +++ b/lua/lualine/components/mode.lua @@ -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 diff --git a/lua/lualine/highlight.lua b/lua/lualine/highlight.lua index 633da64..42b7813 100644 --- a/lua/lualine/highlight.lua +++ b/lua/lualine/highlight.lua @@ -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'