mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-24 17:58:51 +02:00
fix(lazygit): error handling for getting lazygit's config path
This commit is contained in:
parent
2a8bfccc3e
commit
ce5917a589
1 changed files with 16 additions and 2 deletions
|
@ -38,8 +38,22 @@ function M.open(opts)
|
||||||
if M.dirty then
|
if M.dirty then
|
||||||
M.update_config()
|
M.update_config()
|
||||||
end
|
end
|
||||||
M.config_dir = M.config_dir or vim.trim(vim.fn.system("lazygit -cd"))
|
|
||||||
|
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
|
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
|
end
|
||||||
|
|
||||||
return LazyVim.terminal(cmd, opts)
|
return LazyVim.terminal(cmd, opts)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue