add fix
This commit is contained in:
@@ -2,6 +2,7 @@ vim = vim
|
|||||||
local api = vim.api
|
local api = vim.api
|
||||||
local fn = vim.fn
|
local fn = vim.fn
|
||||||
|
|
||||||
|
|
||||||
LAZYGIT_BUFFER = nil
|
LAZYGIT_BUFFER = nil
|
||||||
LAZYGIT_LOADED = false
|
LAZYGIT_LOADED = false
|
||||||
vim.g.lazygit_opened = 0
|
vim.g.lazygit_opened = 0
|
||||||
@@ -23,7 +24,6 @@ end
|
|||||||
|
|
||||||
--- Get project_root_dir for git repository
|
--- Get project_root_dir for git repository
|
||||||
local function project_root_dir()
|
local function project_root_dir()
|
||||||
|
|
||||||
-- always use bash on Unix based systems.
|
-- always use bash on Unix based systems.
|
||||||
local oldshell = vim.o.shell
|
local oldshell = vim.o.shell
|
||||||
if vim.fn.has('win32') == 0 then
|
if vim.fn.has('win32') == 0 then
|
||||||
@@ -31,9 +31,10 @@ local function project_root_dir()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- try symlinked file location instead
|
-- try symlinked file location instead
|
||||||
gitdir = fn.system(
|
local gitdir = fn.system(
|
||||||
'cd "' .. fn.fnamemodify(fn.resolve(fn.expand('%:p')), ':h') .. '" && git rev-parse --show-toplevel')
|
'cd "' .. fn.fnamemodify(fn.resolve(fn.expand('%:p')), ':h') .. '" && git rev-parse --show-toplevel')
|
||||||
isgitdir = fn.matchstr(gitdir, '^fatal:.*') == ''
|
local isgitdir = fn.matchstr(gitdir, '^fatal:.*') == ''
|
||||||
|
|
||||||
if isgitdir then
|
if isgitdir then
|
||||||
vim.o.shell = oldshell
|
vim.o.shell = oldshell
|
||||||
return trim(gitdir)
|
return trim(gitdir)
|
||||||
@@ -152,19 +153,21 @@ local function lazygit(path)
|
|||||||
print('Please install lazygit. Check documentation for more information')
|
print('Please install lazygit. Check documentation for more information')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
open_floating_window()
|
||||||
|
|
||||||
|
local cmd = 'lazygit'
|
||||||
|
-- set path to the root path
|
||||||
|
_ = project_root_dir()
|
||||||
|
|
||||||
if path == nil then
|
if path == nil then
|
||||||
if is_symlink() then
|
if is_symlink() then
|
||||||
path = project_root_dir()
|
path = project_root_dir()
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
cmd = cmd .. ' -p ' .. path
|
||||||
end
|
end
|
||||||
open_floating_window()
|
|
||||||
local cmd = 'lazygit'
|
|
||||||
if path ~= nil and not vim.env.GIT_DIR then
|
|
||||||
cmd = cmd .. ' -g "' .. path .. '/.git/"'
|
|
||||||
end
|
|
||||||
if path ~= nil and not vim.env.GIT_WORK_TREE then
|
|
||||||
cmd = cmd .. ' -w "' .. path .. '"'
|
|
||||||
end
|
|
||||||
exec_lazygit_command(cmd)
|
exec_lazygit_command(cmd)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user