fix(lazygit): check if default config file exists before adding to LG_CONFIG_FILE (#2256)

## Description

I noticed that lazygit was erroring out on open when the default config
file was missing even though lazygit outside of neovim opened fine
without it. Tracked it to the `LG_CONFIG_FILE` var that tells lazygit to
error out when any of the files are missing - and snacks was setting
this to include the default config even when it didn't exist.

## Related Issue(s)

fixes issue: https://github.com/folke/snacks.nvim/issues/1548
This commit is contained in:
Nick deLannoy 2025-10-10 13:39:58 -05:00 committed by GitHub
parent 94f10539a6
commit 3731644e38
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -87,9 +87,12 @@ local function env(opts)
return v:match("%S")
end, vim.split(vim.env.LG_CONFIG_FILE or "", ",", { plain = true }))
-- add the default config file if it's not already there
-- add the default config file if it exists and is not already there
if #config_files == 0 then
config_files[1] = svim.fs.normalize(config_dir .. "/config.yml")
local default_config = svim.fs.normalize(config_dir .. "/config.yml")
if vim.loop.fs_stat(default_config) then
config_files[1] = default_config
end
end
-- add the theme file if it's not already there