Pārlūkot izejas kodu

fix: startify theme button bugfix (#3557)

Gowa2017 2 gadi atpakaļ
vecāks
revīzija
02de1b1e0b
1 mainītis faili ar 8 papildinājumiem un 5 dzēšanām
  1. 8 5
      lua/lvim/core/alpha.lua

+ 8 - 5
lua/lvim/core/alpha.lua

@@ -19,10 +19,14 @@ function M.config()
   }
 end
 
-local function resolve_buttons(theme_name, entries)
+local function resolve_buttons(theme_name, button_section)
+  if button_section.val and #button_section.val > 0 then
+    return button_section.val
+  end
+
   local selected_theme = require("alpha.themes." .. theme_name)
   local val = {}
-  for _, entry in pairs(entries) do
+  for _, entry in pairs(button_section.entries) do
     local on_press = function()
       local sc_ = entry[1]:gsub("%s", ""):gsub("SPC", "<leader>")
       local key = vim.api.nvim_replace_termcodes(sc_, true, false, true)
@@ -32,8 +36,7 @@ local function resolve_buttons(theme_name, entries)
     -- this became necessary after recent changes in alpha.nvim (06ade3a20ca9e79a7038b98d05a23d7b6c016174)
     button_element.on_press = on_press
 
-    button_element.opts =
-      vim.tbl_extend("force", button_element.opts, entry[4] or lvim.builtin.alpha[theme_name].section.buttons.opts)
+    button_element.opts = vim.tbl_extend("force", button_element.opts, entry[4] or button_section.opts or {})
 
     table.insert(val, button_element)
   end
@@ -48,7 +51,7 @@ local function resolve_config(theme_name)
   for name, el in pairs(section) do
     for k, v in pairs(el) do
       if name:match "buttons" and k == "entries" then
-        resolved_section[name].val = resolve_buttons(theme_name, v)
+        resolved_section[name].val = resolve_buttons(theme_name, el)
       elseif v then
         resolved_section[name][k] = v
       end