diff --git a/README.md b/README.md index 97b64af..b6ca227 100644 --- a/README.md +++ b/README.md @@ -158,12 +158,13 @@ The upper part of the popup contains the title, which can also be edited and sen ### Reviewing Diffs -The `review` action will open a diff of the changes. You can leave comments using the `create_comment` action or for multiline comments use `create_multiline_comment` in visual mode. +The `review` action will open a diff of the changes. You can leave comments using the `create_comment` action. In visual mode, add multiline comments with the `create_multiline_comment` command, and add suggested changes with the `create_comment_suggestion` command. ```lua require("gitlab").review() require("gitlab").create_comment() -require("gitlab").create_multiline_comment() +require("gitlab").create_multiline_comment() -- Only supported for diffview reviewer +require("gitlab").create_comment_suggestion() -- Only supported for diffview reviewer ``` For suggesting changes you can use `create_comment_suggestion` in visual mode which works similar to `create_multiline_comment` but prefills the comment window with gitlab [suggest changes](https://docs.gitlab.com/ee/user/project/merge_requests/reviews/suggestions.html) code block with prefilled code from visual selection. @@ -267,7 +268,7 @@ vim.keymap.set("n", "glo", gitlab.open_in_browser) This plugin uses a Golang server to reach out to Gitlab. It's possible that something is going wrong when starting that server or connecting with Gitlab. The Golang server runs outside of Neovim, and can be interacted with directly in order to troubleshoot. To start the server, check out your feature branch and run these commands: -``` +```lua :lua require("gitlab.server").build(true) :lua require("gitlab.server").start(function() print("Server started") end) ``` diff --git a/lua/gitlab/utils/init.lua b/lua/gitlab/utils/init.lua index a750745..8fbc4df 100644 --- a/lua/gitlab/utils/init.lua +++ b/lua/gitlab/utils/init.lua @@ -6,18 +6,17 @@ M.get_current_line_number = function() end M.has_reviewer = function(reviewer) - local has_reviewer if reviewer == "diffview" then - has_reviewer = vim.fn.exists(":DiffviewOpen") ~= 0 + local diffview_ok, _ = pcall(require, "diffview") + if not diffview_ok then + error("Please install diffview or change your reviewer") + end else - has_reviewer = vim.fn.executable("delta") == 1 + local has_reviewer = vim.fn.executable("delta") == 1 + if not has_reviewer then + error(string.format("Please install delta or change your reviewer", reviewer)) + end end - - if not has_reviewer then - error(string.format("Please install %s or change your reviewer", reviewer)) - end - - return has_reviewer end M.is_windows = function()