Add pager option and pipe cmd to pager if exists

git_diff pager: check for empty string
main
Bartosz Mąka 3 years ago committed by bhagwan
parent 11c369316f
commit 9b5fd877e0

@ -177,12 +177,17 @@ function Previewer.git_diff:cmdline(o)
local file = path.entry_to_file(items[1], not self.relative and self.opts.cwd)
local cmd = self.cmd
local args = self.args
local pager = ""
if self.pager and #self.pager>0 and
vim.fn.executable(self.pager) == 1 then
pager = '| ' .. self.pager
end
if is_untracked then args = args .. " --no-index /dev/null" end
if is_deleted then
cmd = self.cmd:gsub("diff", "show HEAD:")
cmd = string.format('%s"%s"', cmd, path.relative(file.path, self.opts.cwd))
else
cmd = string.format('%s %s %s', cmd, args, vim.fn.shellescape(file.path))
cmd = string.format('%s %s %s %s', cmd, args, vim.fn.shellescape(file.path), pager)
end
-- uncomment to see the command in the preview window
-- cmd = vim.fn.shellescape(cmd)

@ -16,6 +16,7 @@ function Previewer:new(o, opts)
self.cmd = o.cmd;
self.args = o.args or "";
self.relative = o.relative
self.pager = o.pager
self.opts = opts;
return self
end

Loading…
Cancel
Save