Add LazyGitCurrentFile command to open floating LazyGit window at project root of current file
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
local open_floating_window = require"lazygit.window".open_floating_window
|
local open_floating_window = require"lazygit.window".open_floating_window
|
||||||
local project_root_dir = require"lazygit.utils".project_root_dir
|
local project_root_dir = require"lazygit.utils".project_root_dir
|
||||||
|
local get_root = require"lazygit.utils".get_root
|
||||||
local is_lazygit_available = require"lazygit.utils".is_lazygit_available
|
local is_lazygit_available = require"lazygit.utils".is_lazygit_available
|
||||||
local is_symlink = require"lazygit.utils".is_symlink
|
local is_symlink = require"lazygit.utils".is_symlink
|
||||||
|
|
||||||
@@ -67,6 +68,13 @@ local function lazygit(path)
|
|||||||
exec_lazygit_command(cmd)
|
exec_lazygit_command(cmd)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- :LazyGitCurrentFile entry point
|
||||||
|
local function lazygitcurrentfile()
|
||||||
|
local current_dir = vim.fn.expand('%:p:h')
|
||||||
|
local git_root = get_root(current_dir)
|
||||||
|
lazygit(git_root)
|
||||||
|
end
|
||||||
|
|
||||||
--- :LazyGitFilter entry point
|
--- :LazyGitFilter entry point
|
||||||
local function lazygitfilter(path)
|
local function lazygitfilter(path)
|
||||||
if is_lazygit_available() ~= true then
|
if is_lazygit_available() ~= true then
|
||||||
@@ -120,6 +128,7 @@ end
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
lazygit = lazygit,
|
lazygit = lazygit,
|
||||||
|
lazygitcurrentfile = lazygitcurrentfile,
|
||||||
lazygitfilter = lazygitfilter,
|
lazygitfilter = lazygitfilter,
|
||||||
lazygitfiltercurrentfile = lazygitfiltercurrentfile,
|
lazygitfiltercurrentfile = lazygitfiltercurrentfile,
|
||||||
lazygitconfig = lazygitconfig,
|
lazygitconfig = lazygitconfig,
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ endif
|
|||||||
|
|
||||||
command! LazyGit lua require'lazygit'.lazygit()
|
command! LazyGit lua require'lazygit'.lazygit()
|
||||||
|
|
||||||
|
command! LazyGitCurrentFile lua require'lazygit'.lazygitcurrentfile()
|
||||||
|
|
||||||
command! LazyGitFilter lua require'lazygit'.lazygitfilter()
|
command! LazyGitFilter lua require'lazygit'.lazygitfilter()
|
||||||
|
|
||||||
command! LazyGitFilterCurrentFile lua require'lazygit'.lazygitfiltercurrentfile()
|
command! LazyGitFilterCurrentFile lua require'lazygit'.lazygitfiltercurrentfile()
|
||||||
|
|||||||
Reference in New Issue
Block a user