mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-05 19:28:24 +00:00
feat(lazygit): respect existing LG_CONFIG_FILE when setting config paths (#208)
## Description This change preserves any existing Lazygit user config while still adding the theme configuration. New Behavior: 1. Check if `LG_CONFIG_FILE` already exists in the environment (`vim.env.LG_CONFIG_FILE`) 2. If it exists, use that value; if not, fall back to the default config path (`vim.fs.normalize(config_dir .. "/config.yml")`) 3. Append the normalized theme configuration path (`opts.theme_path`) --------- Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
This commit is contained in:
parent
833c0667b4
commit
ef114c0efe
1 changed files with 17 additions and 1 deletions
|
@ -81,7 +81,23 @@ local function env(opts)
|
|||
|
||||
if vim.v.shell_error == 0 and #lines > 1 then
|
||||
config_dir = vim.split(lines[1], "\n", { plain = true })[1]
|
||||
vim.env.LG_CONFIG_FILE = vim.fs.normalize(config_dir .. "/config.yml" .. "," .. opts.theme_path)
|
||||
|
||||
---@type string[]
|
||||
local config_files = vim.tbl_filter(function(v)
|
||||
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
|
||||
if #config_files == 0 then
|
||||
config_files[1] = vim.fs.normalize(config_dir .. "/config.yml")
|
||||
end
|
||||
|
||||
-- add the theme file if it's not already there
|
||||
if not vim.tbl_contains(config_files, opts.theme_path) then
|
||||
table.insert(config_files, opts.theme_path)
|
||||
end
|
||||
|
||||
vim.env.LG_CONFIG_FILE = table.concat(config_files, ",")
|
||||
else
|
||||
local msg = {
|
||||
"Failed to get **lazygit** config directory.",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue