From a5f23fd2dbd593fdba9e65b987ca22c9473f5232 Mon Sep 17 00:00:00 2001 From: Mike Date: Thu, 5 Nov 2020 18:54:50 +0000 Subject: [PATCH 1/9] Check nvr exists --- README.md | 2 +- plugin/lazygit.vim | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4d29c5b..61a82a1 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ 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_use_neovim_remote = 1 " fallback to 0 if neovim-remote is not installed ``` Call `:LazyGit` to start a floating window with `lazygit`. diff --git a/plugin/lazygit.vim b/plugin/lazygit.vim index 01514cd..7655ff4 100644 --- a/plugin/lazygit.vim +++ b/plugin/lazygit.vim @@ -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') From 7672859d9c3d5e0445e7e8702a36a0e951cbdba8 Mon Sep 17 00:00:00 2001 From: "Joel D. Elkins" Date: Thu, 21 Jan 2021 12:27:02 -0600 Subject: [PATCH 2/9] Don't use -p if GIT_DIR or GIT_WORK_TREE are set Setting `-p ` is the same as setting `-w -g /.git/`, but this eliminates the possibility that the git dir could be outside of the work tree, or else named something besides `.git`. Use case for me is my configuration files are VC'ed in a git repo, and checked out into `$HOME` (the work tree). The repo is a bare repo elsewhere. --- lua/lazygit.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lua/lazygit.lua b/lua/lazygit.lua index 71c4925..47b7644 100644 --- a/lua/lazygit.lua +++ b/lua/lazygit.lua @@ -147,7 +147,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 From 3a8fb14119c124374c4127090b1f51f5473f49de Mon Sep 17 00:00:00 2001 From: "Joel D. Elkins" Date: Wed, 24 Mar 2021 16:33:44 -0500 Subject: [PATCH 3/9] fnameescape path before calling lazygit --- lua/lazygit.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/lazygit.lua b/lua/lazygit.lua index 47b7644..8d4d412 100644 --- a/lua/lazygit.lua +++ b/lua/lazygit.lua @@ -146,6 +146,7 @@ local function lazygit(path) if path == nil then path = project_root_dir() end + path = vim.fn.fnameescape(path) open_floating_window() local cmd = "lazygit" if not vim.env.GIT_DIR then From e0b272f7715fe1ee95d10293d0c164f4a9e44cf4 Mon Sep 17 00:00:00 2001 From: "Joel D. Elkins" Date: Wed, 24 Mar 2021 17:32:57 -0500 Subject: [PATCH 4/9] Add option to use plenary.nvim to manage floating window --- README.md | 1 + lua/lazygit.lua | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index 61a82a1..2b17cde 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ 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_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 ``` diff --git a/lua/lazygit.lua b/lua/lazygit.lua index 8d4d412..681be58 100644 --- a/lua/lazygit.lua +++ b/lua/lazygit.lua @@ -67,6 +67,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) From 854b6738f1640fdfa774bbf9f612cb2d191d262c Mon Sep 17 00:00:00 2001 From: Dheepak Krishnamurthy Date: Wed, 24 Mar 2021 19:05:53 -0600 Subject: [PATCH 5/9] Add fn.exepath(cmd) --- lua/lazygit.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/lazygit.lua b/lua/lazygit.lua index 8d4d412..b4a42ce 100644 --- a/lua/lazygit.lua +++ b/lua/lazygit.lua @@ -146,9 +146,10 @@ local function lazygit(path) if path == nil then path = project_root_dir() end - path = vim.fn.fnameescape(path) + path = fn.fnameescape(path) open_floating_window() local cmd = "lazygit" + cmd = fn.fnameescape(fn.exepath(cmd)) if not vim.env.GIT_DIR then cmd = cmd .. " -g " .. path .. "/.git/" end From 5787f9b3da6d98ae6c7a96ba01a5fbb6d79b7d34 Mon Sep 17 00:00:00 2001 From: Dheepak Krishnamurthy Date: Wed, 24 Mar 2021 19:15:34 -0600 Subject: [PATCH 6/9] Add double quotes --- lua/lazygit.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lua/lazygit.lua b/lua/lazygit.lua index b4a42ce..188ff3f 100644 --- a/lua/lazygit.lua +++ b/lua/lazygit.lua @@ -146,16 +146,15 @@ local function lazygit(path) if path == nil then path = project_root_dir() end - path = fn.fnameescape(path) open_floating_window() local cmd = "lazygit" - cmd = fn.fnameescape(fn.exepath(cmd)) if not vim.env.GIT_DIR then - cmd = cmd .. " -g " .. path .. "/.git/" + cmd = cmd .. " -g \"" .. path .. "/.git/\"" end if not vim.env.GIT_WORK_TREE then - cmd = cmd .. " -w " .. path + cmd = cmd .. " -w \"" .. path .. "\"" end + print(cmd) exec_lazygit_command(cmd) end From 917bc0a5554d1705a40d3454e3e6ee244619a37e Mon Sep 17 00:00:00 2001 From: Dheepak Krishnamurthy Date: Wed, 24 Mar 2021 19:16:12 -0600 Subject: [PATCH 7/9] Remove print --- lua/lazygit.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/lazygit.lua b/lua/lazygit.lua index 188ff3f..2a58da8 100644 --- a/lua/lazygit.lua +++ b/lua/lazygit.lua @@ -154,7 +154,6 @@ local function lazygit(path) if not vim.env.GIT_WORK_TREE then cmd = cmd .. " -w \"" .. path .. "\"" end - print(cmd) exec_lazygit_command(cmd) end From cb20b05ca781e3d5d2f3707ca43965c4222c2177 Mon Sep 17 00:00:00 2001 From: Dheepak Krishnamurthy Date: Thu, 25 Mar 2021 15:34:45 -0600 Subject: [PATCH 8/9] Update MINRC --- tests/MINRC | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/MINRC b/tests/MINRC index aaf2106..553843c 100644 --- a/tests/MINRC +++ b/tests/MINRC @@ -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() From acc383d1eab516318816f43e3e380fead8249acb Mon Sep 17 00:00:00 2001 From: Dheepak Krishnamurthy Date: Mon, 10 May 2021 00:36:04 -0600 Subject: [PATCH 9/9] Fix submodule bug --- lua/lazygit.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lua/lazygit.lua b/lua/lazygit.lua index 19aaf16..8c80659 100644 --- a/lua/lazygit.lua +++ b/lua/lazygit.lua @@ -18,6 +18,12 @@ end --- Get project_root_dir for git repository local function project_root_dir() + -- 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:.*') == ""