This MR is a #MAJOR breaking change to the plugin. While the plugin will continue to work for users with their existing settings, they will be informed of outdated configuration (diagnostics and signs have been simplified) the next time they open the reviewer.

Fix: Trim trailing slash from custom URLs
Update: .github/CONTRIBUTING.md, .github/ISSUE_TEMPLATE/bug_report.md
Feat: Improve discussion tree toggling (#192)
Fix: Toggle modified notes (#188)
Fix: Toggle discussion nodes correctly
Feat: Show Help keymap in discussion tree winbar
Fix: Enable toggling nodes from the note body
Fix: Enable toggling resolved status from child nodes
Fix: Only try to show emoji popup on note nodes
Feat: Add keymap for toggling tree type
Fix: Disable tree type toggling in Notes
Fix Multi Line Issues (Large Refactor) (#197)
Fix: Multi-line discussions. The calculation of a range for a multiline comment has been consolidated and moved into the location.lua file. This does not attempt to fix diagnostics.
Refactor: It refactors the discussions code to split hunk parsing and management into a separate module
Fix: Don't allow comments on modified buffers #194 by preventing comments on the reviewer when using --imply-local and when the working tree is dirty entirely.
Refactor: It introduces a new List class for data aggregation, filtering, etc.
Fix: It removes redundant API calls and refreshes from the discussion pane
Fix: Location provider (#198)
Fix: add nil check for Diffview performance issue (#199)
Fix: Switch Tabs During Comment Creation (#200)
Fix: Check if file is modified (#201)
Fix: Off-By-One Issue in Old SHA (#202)
Fix: Rebuild Diagnostics + Signs (#203)
Fix: Off-By-One Issue in New SHA (#205)
Fix: Reviewer Jumps to wrong location (#206)

BREAKING CHANGE: Changes configuration of diagnostics and signs in the setup call.
This commit is contained in:
Harrison (Harry) Cramer
2024-03-03 11:52:37 -05:00
committed by GitHub
parent f6a5238d4b
commit b5b475ce8b
31 changed files with 1529 additions and 1298 deletions

View File

@@ -0,0 +1,96 @@
local u = require("gitlab.utils")
local state = require("gitlab.state")
local List = require("gitlab.utils.list")
local discussion_sign_name = require("gitlab.indicators.diagnostics").discussion_sign_name
local namespace = require("gitlab.indicators.diagnostics").diagnostics_namespace
local M = {}
M.clear_signs = function()
vim.fn.sign_unplace(discussion_sign_name)
end
local gitlab_comment = "GitlabComment"
local gitlab_range = "GitlabRange"
local severity_map = {
"Error",
"Warn",
"Info",
"Hint",
}
---Refresh the discussion signs for currently loaded file in reviewer For convinience we use same
---string for sign name and sign group ( currently there is only one sign needed)
---@param diagnostics Diagnostic[]
---@param bufnr number
M.set_signs = function(diagnostics, bufnr)
if not state.settings.discussion_sign.enabled then
return
end
-- Filter diagnostics from the 'gitlab' source and apply custom signs
for _, diagnostic in ipairs(diagnostics) do
---@type SignTable[]
local existing_signs =
vim.fn.sign_getplaced(vim.api.nvim_get_current_buf(), { group = "gitlab_discussion" })[1].signs
local sign_id = string.format("%s__%d", namespace, diagnostic.lnum)
if diagnostic.end_lnum then
local linenr = diagnostic.lnum + 1
while linenr <= diagnostic.end_lnum do
linenr = linenr + 1
local conflicting_comment_sign = List.new(existing_signs):find(function(sign)
return u.ends_with(sign.name, gitlab_comment) and sign.lnum == linenr
end)
if conflicting_comment_sign == nil then
vim.fn.sign_place(
sign_id,
discussion_sign_name,
"DiagnosticSign" .. M.severity .. gitlab_range,
bufnr,
{ lnum = linenr, priority = state.settings.discussion_signs.priority }
)
end
end
end
vim.fn.sign_place(
sign_id,
discussion_sign_name,
"DiagnosticSign" .. M.severity .. gitlab_comment,
bufnr,
{ lnum = diagnostic.lnum + 1, priority = state.settings.discussion_signs.priority }
)
-- TODO: Detect whether diagnostic is ranged and set helper signs
end
end
---Define signs for discussions
M.setup_signs = function()
local discussion_sign_settings = state.settings.discussion_signs
local comment_icon = discussion_sign_settings.icons.comment
local range_icon = discussion_sign_settings.icons.range
M.severity = severity_map[state.settings.discussion_signs.severity]
local signs = { "Error", "Warn", "Hint", "Info" }
for _, type in ipairs(signs) do
-- Define comment highlight group
local hl = "DiagnosticSign" .. type
local comment_hl = hl .. gitlab_comment
vim.fn.sign_define(comment_hl, {
text = comment_icon,
texthl = comment_hl,
})
vim.cmd(string.format("highlight link %s %s", comment_hl, hl))
-- Define range highlight group
local range_hl = hl .. gitlab_range
vim.fn.sign_define(range_hl, {
text = range_icon,
texthl = range_hl,
})
vim.cmd(string.format("highlight link %s %s", range_hl, hl))
end
end
return M