Browse Source

Add a new option to show the mode name in galaxyline (#1303)

Marcelo Cerri 3 years ago
parent
commit
0fbf66e379
2 changed files with 25 additions and 0 deletions
  1. 24 0
      lua/core/galaxyline.lua
  2. 1 0
      lua/core/status_colors.lua

+ 24 - 0
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,

+ 1 - 0
lua/core/status_colors.lua

@@ -1,5 +1,6 @@
 lvim.builtin.galaxyline = {
   active = true,
+  show_mode = false,
   colors = {
     alt_bg = "#2E2E2E",
     grey = "#858585",