diff --git a/lua/octo/commands.lua b/lua/octo/commands.lua index 944bd5bb..0391aa32 100644 --- a/lua/octo/commands.lua +++ b/lua/octo/commands.lua @@ -388,14 +388,14 @@ function M.add_comment() viewerCanDelete = true, viewerDidAuthor = true, reactionGroups = { - { content = "THUMBS_UP", users = { totalCount = 0 } }, + { content = "THUMBS_UP", users = { totalCount = 0 } }, { content = "THUMBS_DOWN", users = { totalCount = 0 } }, - { content = "LAUGH", users = { totalCount = 0 } }, - { content = "HOORAY", users = { totalCount = 0 } }, - { content = "CONFUSED", users = { totalCount = 0 } }, - { content = "HEART", users = { totalCount = 0 } }, - { content = "ROCKET", users = { totalCount = 0 } }, - { content = "EYES", users = { totalCount = 0 } }, + { content = "LAUGH", users = { totalCount = 0 } }, + { content = "HOORAY", users = { totalCount = 0 } }, + { content = "CONFUSED", users = { totalCount = 0 } }, + { content = "HEART", users = { totalCount = 0 } }, + { content = "ROCKET", users = { totalCount = 0 } }, + { content = "EYES", users = { totalCount = 0 } }, }, } @@ -797,8 +797,14 @@ function M.create_pr(is_draft) local local_branch = string.gsub(vim.fn.system(cmd), "%s+", "") -- get remote branches - if info == nil or info.refs == nil or info.refs.nodes == nil or - info == vim.NIL or info.refs == vim.NIL or info.refs.nodes == vim.NIL then + if + info == nil + or info.refs == nil + or info.refs.nodes == nil + or info == vim.NIL + or info.refs == vim.NIL + or info.refs.nodes == vim.NIL + then utils.error "Cannot grab remote branches" return end @@ -813,7 +819,7 @@ function M.create_pr(is_draft) local remote_branch = local_branch if not remote_branch_exists then local choice = - vim.fn.confirm("Remote branch '" .. local_branch .. "' does not exist. Push local one?", "&Yes\n&No\n&Cancel", 2) + vim.fn.confirm("Remote branch '" .. local_branch .. "' does not exist. Push local one?", "&Yes\n&No\n&Cancel", 2) if choice == 1 then local remote = "origin" remote_branch = vim.fn.input { diff --git a/lua/octo/reviews/file-entry.lua b/lua/octo/reviews/file-entry.lua index 664204c1..d35562e6 100644 --- a/lua/octo/reviews/file-entry.lua +++ b/lua/octo/reviews/file-entry.lua @@ -385,7 +385,7 @@ function FileEntry:place_signs() --vim.api.nvim_buf_set_virtual_text(split.bufnr, -1, startLine - 1, { { vt_msg, "Comment" } }, {}) local opts = { virt_text = { { vt_msg, "Comment" } }, - virt_text_pos = 'right_align', + virt_text_pos = "right_align", } vim.api.nvim_buf_set_extmark(split.bufnr, constants.OCTO_REVIEW_COMMENTS_NS, startLine - 1, -1, opts) end diff --git a/lua/octo/ui/writers.lua b/lua/octo/ui/writers.lua index 8fec05f4..ced94151 100644 --- a/lua/octo/ui/writers.lua +++ b/lua/octo/ui/writers.lua @@ -189,7 +189,7 @@ function M.write_state(bufnr, state, number) -- title virtual text local title_vt = { - { tostring(number), "OctoIssueId" }, + { tostring(number), "OctoIssueId" }, { string.format(" [%s] ", state), utils.state_hl_map[state] }, } @@ -254,7 +254,7 @@ function M.write_details(bufnr, issue, update) -- repo local repo_vt = { - { "Repo: ", "OctoDetailsLabel" }, + { "Repo: ", "OctoDetailsLabel" }, { " " .. utils.parse_url(issue.url), "OctoDetailsValue" }, } table.insert(details, repo_vt) @@ -339,7 +339,6 @@ function M.write_details(bufnr, issue, update) local collect_reviewer = function(name, state) --if vim.g.octo_viewer ~= name then if not reviewers[name] then - if vim.g.octo_viewer ~= name then if not reviewers[name] then reviewers[name] = { state } else @@ -350,6 +349,7 @@ function M.write_details(bufnr, issue, update) reviewers[name] = states end end + -- end end local timeline_nodes = {} for _, item in ipairs(issue.timelineItems.nodes) do @@ -378,7 +378,7 @@ function M.write_details(bufnr, issue, update) for _, name in ipairs(vim.tbl_keys(reviewers)) do local strongest_review = utils.calculate_strongest_review_state(reviewers[name]) local reviewer_vt = { - { name, "OctoUser" }, + { name, "OctoUser" }, { " " }, { utils.state_icon_map[strongest_review], utils.state_hl_map[strongest_review] }, { " " }, @@ -402,9 +402,9 @@ function M.write_details(bufnr, issue, update) -- from/into branches local branches_vt = { - { "From: ", "OctoDetailsLabel" }, + { "From: ", "OctoDetailsLabel" }, { issue.headRefName, "OctoDetailsValue" }, - { " Into: ", "OctoDetailsLabel" }, + { " Into: ", "OctoDetailsLabel" }, { issue.baseRefName, "OctoDetailsValue" }, } table.insert(details, branches_vt) @@ -412,7 +412,7 @@ function M.write_details(bufnr, issue, update) -- review decision if issue.reviewDecision and issue.reviewDecision ~= vim.NIL then local decision_vt = { - { "Review decision: ", "OctoDetailsLabel" }, + { "Review decision: ", "OctoDetailsLabel" }, { utils.state_message_map[issue.reviewDecision] }, } table.insert(details, decision_vt) @@ -420,11 +420,11 @@ function M.write_details(bufnr, issue, update) -- changes local changes_vt = { - { "Commits: ", "OctoDetailsLabel" }, - { tostring(issue.commits.totalCount), "OctoDetailsValue" }, - { " Changed files: ", "OctoDetailsLabel" }, - { tostring(issue.changedFiles), "OctoDetailsValue" }, - { " (", "OctoDetailsLabel" }, + { "Commits: ", "OctoDetailsLabel" }, + { tostring(issue.commits.totalCount), "OctoDetailsValue" }, + { " Changed files: ", "OctoDetailsLabel" }, + { tostring(issue.changedFiles), "OctoDetailsValue" }, + { " (", "OctoDetailsLabel" }, { string.format("+%d ", issue.additions), "OctoDiffstatAdditions" }, { string.format("-%d ", issue.deletions), "OctoDiffstatDeletions" }, } @@ -484,7 +484,7 @@ function M.write_comment(bufnr, comment, kind, line) if kind == "PullRequestReview" then -- Review top-level comments local state_bubble = - bubbles.make_bubble(utils.state_msg_map[comment.state], utils.state_hl_map[comment.state] .. "Bubble") + bubbles.make_bubble(utils.state_msg_map[comment.state], utils.state_hl_map[comment.state] .. "Bubble") table.insert(header_vt, { conf.timeline_marker .. " ", "OctoTimelineMarker" }) table.insert(header_vt, { "REVIEW: ", "OctoTimelineItemHeading" }) --vim.list_extend(header_vt, author_bubble) @@ -500,7 +500,7 @@ function M.write_comment(bufnr, comment, kind, line) elseif kind == "PullRequestReviewComment" then -- Review thread comments local state_bubble = - bubbles.make_bubble(comment.state:lower(), utils.state_hl_map[comment.state] .. "Bubble", { margin_width = 1 }) + bubbles.make_bubble(comment.state:lower(), utils.state_hl_map[comment.state] .. "Bubble", { margin_width = 1 }) table.insert( header_vt, { string.rep(" ", 2 * conf.timeline_indent) .. conf.timeline_marker .. " ", "OctoTimelineMarker" } @@ -641,7 +641,7 @@ local function get_lnum_chunks(opts) if not opts.left_line and opts.right_line then return { { string.rep(" ", opts.max_lnum), "DiffAdd" }, - { " ", "DiffAdd" }, + { " ", "DiffAdd" }, { string.rep(" ", opts.max_lnum - vim.fn.strdisplaywidth(tostring(opts.right_line))) .. tostring(opts.right_line), "DiffAdd", @@ -654,9 +654,9 @@ local function get_lnum_chunks(opts) string.rep(" ", opts.max_lnum - vim.fn.strdisplaywidth(tostring(opts.left_line))) .. tostring(opts.left_line), "DiffDelete", }, - { " ", "DiffDelete" }, + { " ", "DiffDelete" }, { string.rep(" ", opts.max_lnum), "DiffDelete" }, - { " ", "DiffDelete" }, + { " ", "DiffDelete" }, } elseif opts.right_line and opts.left_line then return { @@ -762,9 +762,9 @@ function M.write_thread_snippet(bufnr, diffhunk, start_line, comment_start, comm local index = string.find(line, "@[^@]*$") table.insert(vt_lines, { { "│" }, - { string.rep(" ", 2 * max_lnum + 1), "DiffLine" }, - { string.sub(line, 0, index), "DiffLine" }, - { string.sub(line, index + 1), "DiffLine" }, + { string.rep(" ", 2 * max_lnum + 1), "DiffLine" }, + { string.sub(line, 0, index), "DiffLine" }, + { string.sub(line, index + 1), "DiffLine" }, { string.rep(" ", 1 + max_length - vim.fn.strdisplaywidth(line) - 2 * max_lnum), "DiffLine" }, { "│" }, }) @@ -772,7 +772,7 @@ function M.write_thread_snippet(bufnr, diffhunk, start_line, comment_start, comm local vt_line = { { "│" } } vim.list_extend(vt_line, get_lnum_chunks { right_line = map.right_side_lines[i], max_lnum = max_lnum }) vim.list_extend(vt_line, { - { line:gsub("^.", " "), "DiffAdd" }, + { line:gsub("^.", " "), "DiffAdd" }, { string.rep(" ", max_length - vim.fn.strdisplaywidth(line) - 2 * max_lnum), "DiffAdd" }, { "│" }, }) @@ -781,7 +781,7 @@ function M.write_thread_snippet(bufnr, diffhunk, start_line, comment_start, comm local vt_line = { { "│" } } vim.list_extend(vt_line, get_lnum_chunks { left_line = map.left_side_lines[i], max_lnum = max_lnum }) vim.list_extend(vt_line, { - { line:gsub("^.", " "), "DiffDelete" }, + { line:gsub("^.", " "), "DiffDelete" }, { string.rep(" ", max_length - vim.fn.strdisplaywidth(line) - 2 * max_lnum), "DiffDelete" }, { "│" }, }) @@ -826,13 +826,13 @@ function M.write_review_thread_header(bufnr, opts, line) local header_vt = { { string.rep(" ", conf.timeline_indent) .. conf.timeline_marker .. " ", "OctoTimelineMarker" }, - { "THREAD: ", "OctoTimelineItemHeading" }, - { "[", "OctoSymbol" }, - { opts.path .. " ", "OctoDetailsLabel" }, - { tostring(opts.start_line) .. ":" .. tostring(opts.end_line), "OctoDetailsValue" }, - { "] [Commit: ", "OctoSymbol" }, - { opts.commit, "OctoDetailsLabel" }, - { "] ", "OctoSymbol" }, + { "THREAD: ", "OctoTimelineItemHeading" }, + { "[", "OctoSymbol" }, + { opts.path .. " ", "OctoDetailsLabel" }, + { tostring(opts.start_line) .. ":" .. tostring(opts.end_line), "OctoDetailsValue" }, + { "] [Commit: ", "OctoSymbol" }, + { opts.commit, "OctoDetailsLabel" }, + { "] ", "OctoSymbol" }, } if opts.isOutdated then -- local outdated_bubble = bubbles.make_bubble( @@ -933,9 +933,9 @@ function M.write_user_profile(bufnr, user, opts) -- followers/following local follow_chunk = { { " " }, - { "Followers: ", "OctoDetailsValue" }, + { "Followers: ", "OctoDetailsValue" }, { tostring(user.followers.totalCount) }, - { " Following: ", "OctoDetailsValue" }, + { " Following: ", "OctoDetailsValue" }, { tostring(user.following.totalCount) }, } max_length = chunk_length(max_length, follow_chunk) @@ -1026,7 +1026,7 @@ function M.write_issue_summary(bufnr, issue, opts) -- repo and date line table.insert(chunks, { { " " }, - { issue.repository.nameWithOwner, "OctoDetailsValue" }, + { issue.repository.nameWithOwner, "OctoDetailsValue" }, { " " .. utils.format_date(issue.createdAt), "OctoDetailsValue" }, }) @@ -1034,7 +1034,7 @@ function M.write_issue_summary(bufnr, issue, opts) table.insert(chunks, { { " " }, { "[" .. issue.state .. "] ", utils.state_hl_map[issue.state] }, - { issue.title .. " ", "OctoDetailsLabel" }, + { issue.title .. " ", "OctoDetailsLabel" }, { "#" .. issue.number .. " ", "OctoDetailsValue" }, }) table.insert(chunks, { { "" } }) @@ -1065,11 +1065,11 @@ function M.write_issue_summary(bufnr, issue, opts) if issue.__typename == "PullRequest" then table.insert(chunks, { { " " }, - { "[", "OctoDetailsValue" }, + { "[", "OctoDetailsValue" }, { issue.baseRefName, "OctoDetailsLabel" }, - { "] ⟵ [", "OctoDetailsValue" }, + { "] ⟵ [", "OctoDetailsValue" }, { issue.headRefName, "OctoDetailsLabel" }, - { "]", "OctoDetailsValue" }, + { "]", "OctoDetailsValue" }, }) table.insert(chunks, { { "" } }) end @@ -1301,7 +1301,7 @@ function M.write_threads(bufnr, threads) -- review thread header if utils.is_blank(comment.replyTo) then local start_line = not utils.is_blank(thread.originalStartLine) and thread.originalStartLine - or thread.originalLine + or thread.originalLine local end_line = thread.originalLine comment.start_line = start_line comment.end_line = end_line @@ -1321,7 +1321,7 @@ function M.write_threads(bufnr, threads) -- write snippet thread_start, thread_end = - M.write_thread_snippet(bufnr, comment.diffHunk, nil, start_line, end_line, thread.diffSide) + M.write_thread_snippet(bufnr, comment.diffHunk, nil, start_line, end_line, thread.diffSide) end comment_start, comment_end = M.write_comment(bufnr, comment, "PullRequestReviewComment")