From daa4cd45b3e366270727a2d6e437fcd32ec8bd59 Mon Sep 17 00:00:00 2001 From: shadmansaleh Date: Sun, 14 Mar 2021 20:14:19 +0600 Subject: [PATCH] Restructure mode conponent --- lua/lualine/components/mode.lua | 71 ++++++++++++++++----------------- 1 file changed, 34 insertions(+), 37 deletions(-) diff --git a/lua/lualine/components/mode.lua b/lua/lualine/components/mode.lua index c3218b6..57daf6a 100644 --- a/lua/lualine/components/mode.lua +++ b/lua/lualine/components/mode.lua @@ -1,44 +1,41 @@ -- Copyright (c) 2020-2021 hoob3rt -- 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 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 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() + 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 mode