Added command to open diffview
This commit is contained in:
@@ -10,6 +10,20 @@ local function get_git_root()
|
||||
end
|
||||
end
|
||||
|
||||
local branch_exists = function(b)
|
||||
local is_git_branch = io.popen("git rev-parse --is-inside-work-tree 2>/dev/null"):read("*a")
|
||||
if is_git_branch == "true\n" then
|
||||
for line in io.popen("git branch 2>/dev/null"):lines() do
|
||||
line = line:gsub("%s+", "")
|
||||
if line == b then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
local function get_relative_file_path()
|
||||
local git_root = get_git_root()
|
||||
if git_root ~= nil then
|
||||
@@ -118,6 +132,7 @@ end
|
||||
|
||||
|
||||
local function jump_to_file(filename, line_number)
|
||||
if line_number == nil then line_number = 1 end
|
||||
vim.api.nvim_command("wincmd l")
|
||||
local bufnr = vim.fn.bufnr(filename)
|
||||
if bufnr ~= -1 then
|
||||
@@ -244,5 +259,6 @@ M.create_popup_state = create_popup_state
|
||||
M.exit = exit
|
||||
M.read_file = read_file
|
||||
M.split_diff_view_filename = split_diff_view_filename
|
||||
M.branch_exists = branch_exists
|
||||
M.P = P
|
||||
return M
|
||||
|
||||
Reference in New Issue
Block a user