Skip to content

create_comment works only in review pannel #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mrparalon opened this issue Aug 28, 2023 · 2 comments
Closed

create_comment works only in review pannel #49

mrparalon opened this issue Aug 28, 2023 · 2 comments
Labels
feature request New feature or request

Comments

@mrparalon
Copy link
Contributor

On the latest version of plugin, .create_comment() works only from review panel.

Error message Delta reviewer must be initialized first

I'm using diffview to review MRs.

Is it possible to make it work without Delta reviewer?

@harrisoncramer
Copy link
Owner

harrisoncramer commented Aug 28, 2023

This is by design. The reason is because we need to get the current line information from the reviewer in order to make a comment to Github's APIs.

Please see this discussion for more context: #25

If we want to add a reviewer, it would have to implement the functions at lua/gitlab/reviewer/init.lua

-- This Module will pick the reviewer set in the user's
-- settings and then map all of it's functions
local state = require("gitlab.state")
local delta = require("gitlab.reviewer.delta")

local M = {
  reviewer = nil,
}

local reviewer_map = {
  delta = delta
}

M.init = function()
  local reviewer = reviewer_map[state.settings.reviewer]
  if reviewer == nil then
    vim.notify(string.format("gitlab.nvim could not find reviewer %s", state.settings.reviewer), vim.log.levels.ERROR)
    return
  end

  M.open = reviewer.open
  -- Opens the reviewer window

  M.jump = reviewer.jump
  -- Jumps to the location provided in the reviewer window
  -- Parameters:
  --   • {file_name}      The name of the file to jump to
  --   • {new_line}  The new_line of the change
  --   • {interval}  The old_line of the change

  M.get_location = reviewer.get_location
  -- Returns the current location (based on cursor) from the reviewer window (file_name, line_numbers, error) where line_numbers is a lua table like this: { old_line: old_line_num, new_line: new_line_num }
end

return M

These functions pull information from the current buffer and pass it to the comment module, which will send the comment to Gitlab. I'm intending to work on supporting Diffview (this is the reviewer that I've used in the past as well) but haven't gotten to it yet.

@harrisoncramer harrisoncramer added the feature request New feature or request label Aug 28, 2023
@mrparalon
Copy link
Contributor Author

Thanks for direction, I'll try to add diffview reviewer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants