Bläddra i källkod

fix(dashboard): hide version when no tag found (#1572)

chaesngmin 3 år sedan
förälder
incheckning
390f277b70
2 ändrade filer med 15 tillägg och 6 borttagningar
  1. 5 1
      lua/bootstrap.lua
  2. 10 5
      lua/core/dashboard.lua

+ 5 - 1
lua/bootstrap.lua

@@ -33,7 +33,11 @@ function _G.get_cache_dir()
 end
 
 function _G.get_version(type)
-  local lvim_full_ver = vim.fn.system("git -C " .. get_runtime_dir() .. "/lvim describe --tag")
+  local lvim_full_ver = vim.fn.system("git -C " .. get_runtime_dir() .. "/lvim describe --tags")
+
+  if string.match(lvim_full_ver, "%d") == nil then
+    return nil
+  end
   if type == "short" then
     return vim.fn.split(lvim_full_ver, "-")[1]
   else

+ 10 - 5
lua/core/dashboard.lua

@@ -73,14 +73,19 @@ M.setup = function()
   local lvim_version = get_version "short"
   local num_plugins_loaded = #vim.fn.globpath(get_runtime_dir() .. "/site/pack/packer/start", "*", 0, 1)
 
-  local text = require "interface.text"
-  vim.g.dashboard_custom_footer = text.align_center({ width = 0 }, {
+  local footer = {
     "LunarVim loaded " .. num_plugins_loaded .. " plugins ",
     "",
-    "v" .. lvim_version,
-    "",
     lvim_site,
-  }, 0.49) -- Use 0.49 as  counts for 2 characters
+  }
+
+  if lvim_version then
+    table.insert(footer, 2, "")
+    table.insert(footer, 3, "v" .. lvim_version)
+  end
+
+  local text = require "interface.text"
+  vim.g.dashboard_custom_footer = text.align_center({ width = 0 }, footer, 0.49) -- Use 0.49 as  counts for 2 characters
 
   require("core.autocmds").define_augroups {
     _dashboard = {