feat(lazygit): allow user to override LazyVim config with custom file

This commit is contained in:
Iordanis Petkakis 2024-08-28 20:15:16 +03:00
parent 12818a6cb4
commit c5924d2e29
2 changed files with 10 additions and 3 deletions

View file

@ -20,9 +20,12 @@ vim.g.root_spec = { "lsp", { ".git", "lua" }, "cwd" }
-- LazyVim automatically configures lazygit:
-- * theme, based on the active colorscheme.
-- * editorPreset to nvim-remote
-- * editPreset to nvim-remote
-- * enables nerd font icons
-- Set to false to disable.
-- Set the options you want to override in `~/.config/lazygit/custom.yml`
-- WARN: on Windows you might want to set `editPreset: "nvim"` due to
-- this issue https://github.com/jesseduffield/lazygit/issues/3467
vim.g.lazygit_config = true
-- Options for the LazyVim statuscolumn

View file

@ -70,6 +70,10 @@ function M.open(opts)
if ok then
M.config_dir = lines[1]
vim.env.LG_CONFIG_FILE = LazyVim.norm(M.config_dir .. "/config.yml" .. "," .. M.theme_path)
local custom_config = LazyVim.norm(M.config_dir .. "/custom.yml")
if vim.uv.fs_stat(custom_config) and vim.uv.fs_stat(custom_config).type == "file" then
vim.env.LG_CONFIG_FILE = vim.env.LG_CONFIG_FILE .. "," .. custom_config
end
else
---@diagnostic disable-next-line: cast-type-mismatch
---@cast lines string
@ -130,9 +134,9 @@ gui:
---@type string[]
local lines = {}
for k, v in pairs(theme) do
lines[#lines + 1] = (" %s:"):format(k)
lines[#lines + 1] = (" %s:"):format(k)
for _, c in ipairs(v) do
lines[#lines + 1] = (" - %q"):format(c)
lines[#lines + 1] = (" - %q"):format(c)
end
end
config = config .. table.concat(lines, "\n")