Skip to content

Commit 5447ea0

Browse files
committed
perf(lazygit): optimize lazygit setting
1 parent 5db873d commit 5447ea0

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

lua/astroui/lazygit.lua

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function M.update_config()
3939
for k, v in pairs(tbl) do
4040
table.insert(lines, string.rep(" ", indent) .. k .. (type(v) == "table" and ":" or ": " .. yaml_val(v)))
4141
if type(v) == "table" then
42-
if (vim.islist or vim.tbl_islist)(v) then
42+
if vim.islist(v) then
4343
for _, item in ipairs(v) do
4444
table.insert(lines, string.rep(" ", indent + 2) .. "- " .. yaml_val(item))
4545
end
@@ -56,22 +56,24 @@ end
5656
function M.setup()
5757
if type(config) ~= "table" then return end
5858

59-
M.update_config()
59+
if config.theme_path then
60+
if not vim.uv.fs_stat(config.theme_path) then vim.schedule(M.update_config) end
6061

61-
local lg_config_file = vim.env.LG_CONFIG_FILE --[[ @as string? ]]
62-
if not lg_config_file and vim.fn.executable "lazygit" == 1 then
63-
lg_config_file = require("astrocore").cmd({ "lazygit", "-cd" }, false)
64-
if lg_config_file then lg_config_file = vim.split(lg_config_file, "\n", { plain = true })[1] .. "/config.yml" end
65-
end
66-
lg_config_file = lg_config_file and lg_config_file .. "," or ""
67-
vim.env.LG_CONFIG_FILE = vim.fs.normalize(lg_config_file .. config.theme_path)
62+
local lg_config_file = vim.env.LG_CONFIG_FILE --[[ @as string? ]]
63+
if not lg_config_file and vim.fn.executable "lazygit" == 1 then
64+
lg_config_file = require("astrocore").cmd({ "lazygit", "-cd" }, false)
65+
if lg_config_file then lg_config_file = vim.split(lg_config_file, "\n", { plain = true })[1] .. "/config.yml" end
66+
end
67+
lg_config_file = lg_config_file and lg_config_file .. "," or ""
68+
vim.env.LG_CONFIG_FILE = vim.fs.normalize(lg_config_file .. config.theme_path)
6869

69-
vim.api.nvim_create_autocmd("User", {
70-
pattern = "AstroColorScheme",
71-
group = vim.api.nvim_create_augroup("astroui_lazygit", { clear = true }),
72-
desc = "Update lazygit theme configuration when changing colorscheme",
73-
callback = M.update_config,
74-
})
70+
vim.api.nvim_create_autocmd("User", {
71+
pattern = "AstroColorScheme",
72+
group = vim.api.nvim_create_augroup("astroui_lazygit", { clear = true }),
73+
desc = "Update lazygit theme configuration when changing colorscheme",
74+
callback = function() vim.schedule(M.update_config) end,
75+
})
76+
end
7577
end
7678

7779
return M

0 commit comments

Comments
 (0)