Skip to content

Commit

Permalink
fix(lazygit): error handling for getting lazygit's config path
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Mar 27, 2024
1 parent 2a8bfcc commit ce5917a
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lua/lazyvim/util/lazygit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,22 @@ function M.open(opts)
if M.dirty then
M.update_config()
end
M.config_dir = M.config_dir or vim.trim(vim.fn.system("lazygit -cd"))
vim.env.LG_CONFIG_FILE = M.config_dir .. "/config.yml" .. "," .. M.theme_path

if not M.config_dir then
local Process = require("lazy.manage.process")
local ok, lines = pcall(Process.exec, { "lazygit", "-cd" })
if ok then
M.config_dir = lines[1]
vim.env.LG_CONFIG_FILE = M.config_dir .. "/config.yml" .. "," .. M.theme_path
else
---@diagnostic disable-next-line: cast-type-mismatch
---@cast lines string
LazyVim.error(
{ "Failed to get **lazygit** config directory.", "Will not apply **lazygit** config.", "", "# Error:", lines },
{ title = "lazygit" }
)
end
end
end

return LazyVim.terminal(cmd, opts)
Expand Down

0 comments on commit ce5917a

Please sign in to comment.