feat: change custom config file logic ✨
This commit is contained in:
@@ -47,24 +47,10 @@ local function exec_lazygit_command(cmd)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function lazygitdefaultconfigpath()
|
local function lazygitdefaultconfigpath()
|
||||||
local os_name = vim.loop.os_uname().sysname
|
return fn.substitute(fn.system("lazygit -cd"), "\n", "", "")
|
||||||
|
|
||||||
-- TODO: not surer if vim.loop.os_uname() has the same result
|
|
||||||
-- check before replacing the following line
|
|
||||||
local os = fn.substitute(fn.system("uname"), "\n", "", "")
|
|
||||||
if os == "Darwin" then
|
|
||||||
return "~/Library/Application\\ Support/lazygit/config.yml"
|
|
||||||
else
|
|
||||||
if string.find(os_name, "Window") then
|
|
||||||
return "%APPDATA%/lazygit/config.yml"
|
|
||||||
else
|
|
||||||
return "~/.config/lazygit/config.yml"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function lazygitgetconfigpath()
|
local function lazygitgetconfigpath()
|
||||||
if vim.g.lazygit_use_custom_config_file_path == 1 then
|
|
||||||
if vim.g.lazygit_config_file_path then
|
if vim.g.lazygit_config_file_path then
|
||||||
-- if file exists
|
-- if file exists
|
||||||
if fn.empty(fn.glob(vim.g.lazygit_config_file_path)) == 0 then
|
if fn.empty(fn.glob(vim.g.lazygit_config_file_path)) == 0 then
|
||||||
@@ -75,7 +61,6 @@ local function lazygitgetconfigpath()
|
|||||||
else
|
else
|
||||||
print("lazygit: custom config file path is not set, option: 'lazygit_config_file_path' is missing")
|
print("lazygit: custom config file path is not set, option: 'lazygit_config_file_path' is missing")
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
-- any issue with the config file we fallback to the default config file path
|
-- any issue with the config file we fallback to the default config file path
|
||||||
return lazygitdefaultconfigpath()
|
return lazygitdefaultconfigpath()
|
||||||
@@ -97,9 +82,9 @@ local function lazygit(path)
|
|||||||
-- set path to the root path
|
-- set path to the root path
|
||||||
_ = project_root_dir()
|
_ = project_root_dir()
|
||||||
|
|
||||||
-- print(lazygitgetconfigpath())
|
if vim.g.lazygit_use_custom_config_file_path == 1 then
|
||||||
|
|
||||||
cmd = cmd .. " -ucf " .. lazygitgetconfigpath()
|
cmd = cmd .. " -ucf " .. lazygitgetconfigpath()
|
||||||
|
end
|
||||||
|
|
||||||
if path == nil then
|
if path == nil then
|
||||||
if is_symlink() then
|
if is_symlink() then
|
||||||
|
|||||||
Reference in New Issue
Block a user