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

@@ -33,7 +33,8 @@ The following are configuration options and their defaults.
let g:lazygit_floating_window_winblend = 0 " transparency of floating window
let g:lazygit_floating_window_scaling_factor = 0.9 " scaling factor for floating window
let g:lazygit_floating_window_corner_chars = ['╭', '╮', '╰', '╯'] " customize lazygit popup window corner characters
let g:lazygit_use_neovim_remote = 1 " for neovim-remote support
let g:lazygit_floating_window_use_plenary = 0 " use plenary.nvim to manage floating window if available
let g:lazygit_use_neovim_remote = 1 " fallback to 0 if neovim-remote is not installed
```
Call `:LazyGit` to start a floating window with `lazygit`.

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

View File

@@ -16,7 +16,7 @@ if !exists('g:lazygit_floating_window_scaling_factor')
endif
if !exists('g:lazygit_use_neovim_remote')
let g:lazygit_use_neovim_remote = 1
let g:lazygit_use_neovim_remote = executable('nvr') ? 1 : 0
endif
if !exists('g:lazygit_floating_window_corner_chars')

View File

@@ -11,7 +11,7 @@ endif
call plug#begin('~/.local/share/nvim/plugged')
Plug '~/gitrepos/lazygit.vim'
Plug '~/gitrepos/lazygit.nvim'
" Initialize plugin system
call plug#end()