Add lazygitfilter
This commit is contained in:
@@ -30,8 +30,7 @@ local function project_root_dir()
|
|||||||
return fn.getcwd()
|
return fn.getcwd()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function exec_lazygit_command(root_dir)
|
local function exec_lazygit_command(cmd)
|
||||||
local cmd = "lazygit " .. "-p " .. root_dir
|
|
||||||
if ( fn.has("win64") == 0 and fn.has("win32") == 0 and fn.has("win16") == 0 ) then
|
if ( fn.has("win64") == 0 and fn.has("win32") == 0 and fn.has("win16") == 0 ) then
|
||||||
cmd = "GIT_EDITOR=nvim " .. cmd
|
cmd = "GIT_EDITOR=nvim " .. cmd
|
||||||
end
|
end
|
||||||
@@ -113,15 +112,31 @@ local function on_exit(job_id, code, event)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function lazygit()
|
local function lazygit(path)
|
||||||
if is_lazygit_available() ~= true then
|
if is_lazygit_available() ~= true then
|
||||||
print("Please install lazygit. Check documentation for more information")
|
print("Please install lazygit. Check documentation for more information")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
-- TODO: ensure that it is a valid git directory
|
if path == nil then
|
||||||
local root_dir = project_root_dir()
|
path = project_root_dir()
|
||||||
|
end
|
||||||
open_floating_window()
|
open_floating_window()
|
||||||
exec_lazygit_command(root_dir)
|
local cmd = "lazygit " .. "-p " .. path
|
||||||
|
exec_lazygit_command(cmd)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function lazygitfilter(path)
|
||||||
|
if is_lazygit_available() ~= true then
|
||||||
|
print("Please install lazygit. Check documentation for more information")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if path == nil then
|
||||||
|
path = project_root_dir()
|
||||||
|
end
|
||||||
|
open_floating_window()
|
||||||
|
local cmd = "lazygit " .. "-f " .. path
|
||||||
|
exec_lazygit_command(cmd)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function lazygitconfig()
|
local function lazygitconfig()
|
||||||
@@ -154,6 +169,7 @@ end
|
|||||||
return {
|
return {
|
||||||
setup = setup,
|
setup = setup,
|
||||||
lazygit = lazygit,
|
lazygit = lazygit,
|
||||||
|
lazygitfilter = lazygitfilter,
|
||||||
lazygitconfig = lazygitconfig,
|
lazygitconfig = lazygitconfig,
|
||||||
on_exit = on_exit,
|
on_exit = on_exit,
|
||||||
on_buf_leave = on_buf_leave,
|
on_buf_leave = on_buf_leave,
|
||||||
|
|||||||
Reference in New Issue
Block a user