Merge branch 'master' into bug/support-fish-shell

This commit is contained in:
Dheepak Krishnamurthy
2021-07-07 21:33:45 -06:00
committed by GitHub
4 changed files with 24 additions and 4 deletions

View File

@@ -18,10 +18,17 @@ end
--- Get project_root_dir for git repository
local function project_root_dir()
-- always use bash
local oldshell = vim.o.shell
vim.o.shell = 'bash'
-- try submodule first
local gitdir = fn.system('cd "' .. fn.expand('%:p:h') .. '" && git rev-parse --show-superproject-working-tree')
if gitdir ~= "" then
return trim(gitdir)
end
-- try file location first
local gitdir = fn.system('cd "' .. fn.expand('%:p:h') .. '" && git rev-parse --show-toplevel')
local isgitdir = fn.matchstr(gitdir, '^fatal:.*') == ""
@@ -74,6 +81,12 @@ local function open_floating_window()
floating_window_scaling_factor = floating_window_scaling_factor[false]
end
local status, plenary = pcall(require, 'plenary.window.float')
if status and vim.g.lazygit_floating_window_use_plenary and vim.g.lazygit_floating_window_use_plenary ~= 0 then
plenary.percentage_range_window(floating_window_scaling_factor, floating_window_scaling_factor)
return
end
local height = math.ceil(vim.o.lines * floating_window_scaling_factor) - 1
local width = math.ceil(vim.o.columns * floating_window_scaling_factor)
@@ -154,7 +167,13 @@ local function lazygit(path)
path = project_root_dir()
end
open_floating_window()
local cmd = "lazygit " .. "-p " .. path
local cmd = "lazygit"
if not vim.env.GIT_DIR then
cmd = cmd .. " -g \"" .. path .. "/.git/\""
end
if not vim.env.GIT_WORK_TREE then
cmd = cmd .. " -w \"" .. path .. "\""
end
exec_lazygit_command(cmd)
end