Follow-up: Require Different Reviewers

This plugin previously only supported the Delta reviewer. Thanks to work
from @mrparalon it now supports Diffview also. This MR adjusts the
requirements to account for this, and the README.

It also addresses a small bug in the original implementation regarding
an async file opening action, and applies formatting to the diffview
file consistent with the rest of the project
This commit is contained in:
Harrison Cramer
2023-09-05 10:22:19 -04:00
parent a2bd0749f0
commit 4792e03416
6 changed files with 83 additions and 67 deletions

View File

@@ -4,8 +4,19 @@ M.get_current_line_number = function()
return vim.api.nvim_call_function('line', { '.' })
end
M.has_delta = function()
return vim.fn.executable("delta") == 1
M.has_reviewer = function(reviewer)
local has_reviewer = false
if reviewer == "diffview" then
has_reviewer = vim.fn.exists(":DiffviewOpen") ~= 0
else
has_reviewer = vim.fn.executable("delta") == 1
end
if not has_reviewer then
error(string.format("Please install %s or change your reviewer", reviewer))
end
return has_reviewer
end
M.P = function(...)