Skip to content

Commit

Permalink
Lint: fix stylua
Browse files Browse the repository at this point in the history
  • Loading branch information
Alvaro Muñoz committed Aug 28, 2023
1 parent 695cd07 commit d1e52f9
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 49 deletions.
26 changes: 16 additions & 10 deletions lua/octo/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 } },
},
}

Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion lua/octo/reviews/file-entry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
76 changes: 38 additions & 38 deletions lua/octo/ui/writers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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] },
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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] },
{ " " },
Expand All @@ -402,29 +402,29 @@ 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)

-- 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)
end

-- 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" },
}
Expand Down Expand Up @@ -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)
Expand All @@ -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" }
Expand Down Expand Up @@ -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",
Expand All @@ -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 {
Expand Down Expand Up @@ -762,17 +762,17 @@ 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" },
{ "" },
})
elseif vim.startswith(line, "+") then
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" },
{ "" },
})
Expand All @@ -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" },
{ "" },
})
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -1026,15 +1026,15 @@ 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" },
})

-- issue body
table.insert(chunks, {
{ " " },
{ "[" .. issue.state .. "] ", utils.state_hl_map[issue.state] },
{ issue.title .. " ", "OctoDetailsLabel" },
{ issue.title .. " ", "OctoDetailsLabel" },
{ "#" .. issue.number .. " ", "OctoDetailsValue" },
})
table.insert(chunks, { { "" } })
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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")
Expand Down

0 comments on commit d1e52f9

Please sign in to comment.