Skip to content

Commit

Permalink
Winbar Support + Notes and Discussions; Help Popup + Auto-Open (#133)
Browse files Browse the repository at this point in the history
- Adds support for toggling between discussions and notes views
- Deprecates the split view shared with both discussions and notes at the same time
- Adds winbar to discussion split, with metadata about resolved and unresolved discussions
- Adds help popups with information about keybindings for all views
- Modifies highlights in discussion tree and default symbol for unresolved discussions

This is a MINOR version bump as the default behavior of the discussion tree is changed slightly. Existing configurations should still function.
  • Loading branch information
harrisoncramer authored Dec 13, 2023
1 parent d5038d6 commit d5510f9
Show file tree
Hide file tree
Showing 13 changed files with 588 additions and 428 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ require("gitlab").setup({
config_path = nil, -- Custom path for `.gitlab.nvim` file, please read the "Connecting to Gitlab" section
debug = { go_request = false, go_response = false }, -- Which values to log
attachment_dir = nil, -- The local directory for files (see the "summary" section)
help = "?", -- Opens a help popup for local keymaps when a relevant view is focused (popup, discussion panel, etc)
popup = { -- The popup for comment creation, editing, and replying
exit = "<Esc>",
perform_action = "<leader>s", -- Once in normal mode, does action (like saving comment or editing description, etc)
Expand All @@ -132,6 +133,9 @@ require("gitlab").setup({
reply = nil,
},
discussion_tree = { -- The discussion tree that holds all comments
auto_open = true, -- Automatically open when the reviewer is opened
switch_view = "T", -- Toggles between the notes and discussions views
default_view = "discussions" -- Show "discussions" or "notes" by default
blacklist = {}, -- List of usernames to remove from tree (bots, CI, etc)
jump_to_file = "o", -- Jump to comment location in file
jump_to_reviewer = "m", -- Jump to the location in the reviewer window
Expand All @@ -146,6 +150,8 @@ require("gitlab").setup({
resolved = '', -- Symbol to show next to resolved discussions
unresolved = '', -- Symbol to show next to unresolved discussions
tree_type = "simple", -- Type of discussion tree - "simple" means just list of discussions, "by_file_name" means file tree with discussions under file
winbar = nil -- Custom function to return winbar title, should return a string. Provided with WinbarTable (defined in annotations.lua)
-- If using lualine, please add "gitlab" to disabled file types, otherwise you will not see the winbar.
},
info = { -- Show additional fields in the summary pane
enabled = true,
Expand Down
4 changes: 4 additions & 0 deletions after/syntax/gitlab.vim
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ syntax match Username "@\S*"
syntax match Date "\v\d+\s+\w+\s+ago"
syntax match ChevronDown ""
syntax match ChevronRight ""
syntax match Resolved "✓$"
syntax match Unresolved "-$"

highlight link Username GitlabUsername
highlight link Date GitlabDate
highlight link ChevronDown GitlabChevron
highlight link ChevronRight GitlabChevron
highlight link Resolved GitlabResolved
highlight link Unresolved GitlabUnresolved

let b:current_syntax = "gitlab"
1 change: 1 addition & 0 deletions lua/gitlab/actions/comment.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ M.confirm_create_comment = function(text, range, unlinked)
job.run_job("/comment", "POST", body, function(data)
u.notify("Note created!", vim.log.levels.INFO)
discussions.add_discussion({ data = data, unlinked = true })
discussions.refresh_discussion_data()
end)
return
end
Expand Down
7 changes: 7 additions & 0 deletions lua/gitlab/actions/discussions/annotations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,10 @@
---@class DiscussionData
---@field discussions Discussion[]
---@field unlinked_discussions UnlinkedDiscussion[]

---@class WinbarTable
---@field name string
---@field resolvable_discussions number
---@field resolved_discussions number
---@field resolvable_notes number
---@field resolved_notes number
Loading

0 comments on commit d5510f9

Please sign in to comment.