summaryrefslogtreecommitdiff
path: root/lua/core/galaxyline.lua
diff options
context:
space:
mode:
authorMarcelo Cerri <[email protected]>2021-08-14 16:56:37 -0300
committerGitHub <[email protected]>2021-08-15 00:26:37 +0430
commit0fbf66e379f10d816d875583f6805ab7e3ea9e78 (patch)
treee0ec5002a93bfe4300dd59745c0002bf3c6f7ff8 /lua/core/galaxyline.lua
parentae118c5afc0a533118059a4681a2736055e8a2bc (diff)
Add a new option to show the mode name in galaxyline (#1303)
Diffstat (limited to 'lua/core/galaxyline.lua')
-rw-r--r--lua/core/galaxyline.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/lua/core/galaxyline.lua b/lua/core/galaxyline.lua
index 512dd78c..0f31ef53 100644
--- a/lua/core/galaxyline.lua
+++ b/lua/core/galaxyline.lua
@@ -18,6 +18,20 @@ local condition = require "galaxyline.condition"
local gls = gl.section
gl.short_line_list = { "NvimTree", "vista", "dbui", "packer" }
+local function get_mode_name()
+ local names = {
+ n = "NORMAL",
+ i = "INSERT",
+ c = "COMMAND",
+ v = "VISUAL",
+ V = "VISUAL LINE",
+ t = "TERMINAL",
+ R = "REPLACE",
+ [""] = "VISUAL BLOCK",
+ }
+ return names[vim.fn.mode()]
+end
+
table.insert(gls.left, {
ViMode = {
provider = function()
@@ -44,6 +58,16 @@ table.insert(gls.left, {
["!"] = colors.blue,
t = colors.blue,
}
+ if lvim.builtin.galaxyline.show_mode then
+ local name = get_mode_name()
+ -- Fall back to the default behavior is a name is not defined
+ if name ~= nil then
+ vim.api.nvim_command("hi GalaxyViMode guibg=" .. mode_color[vim.fn.mode()])
+ vim.api.nvim_command("hi GalaxyViMode guifg=" .. colors.alt_bg)
+ return " " .. name .. " "
+ end
+ end
+ vim.api.nvim_command("hi GalaxyViMode guibg=" .. colors.alt_bg)
vim.api.nvim_command("hi GalaxyViMode guifg=" .. mode_color[vim.fn.mode()])
return "â–Š"
end,