Skip to content

Commit e4eabaf

Browse files
harrisoncramerjakubbortlikduckbrainkitsioskmakbari
authored
Release 1/24/26 (#519)
* Fix: Jumping to renamed files (#484) * fix: prevent "cursor position outside buffer" error * fix: swap file_name and old_file_name in reviewer data `old_file_name` is not set to the empty string for un-renamed files anymore, because then we can remove the empty-line check in `comment_helpers.go` which was used to replace the empty string with the current file name anyway. * fix: add old_file_name to discussion root node data * fix: also consider old_file_name when jumping to the reviewer This fixes jumping to renamed files, however, may not work for comments that were created on renamed files with the previous version of `gitlab.nvim` as that version assigned the `file_name` and `old_file_name` incorrectly. * refactor: don't shadow variable * fix: check file_name or old_file_name based on which SHA comment belongs to * Fix: Store reviewer data before creating comment popup (#476) * Fix: Make publishing drafts more robust (#483) * Fix: Swap file_name and old_file_name in reviewer data (#485) * Feat: Enable toggling date format between relative and absolute (#491) * Fix: Add opts to help popup (#492) * Fix: Force start_line for jumping to diagnostic to be inside buffer (#494) * fix: redefine colors after reloading colorscheme (#500) * Fix: Use path instead of oldpath as fallback for unrenamed files (#496) * Fix: Use file_name when old_file_name is not set (#495) * fix(ci): fix lua tests (#501) * Proxy Support (#499) * feat(ci): Cancel obsolete after a new commit is pushed in an open PR (#503) * fix: start and clean up winbar timer properly (#513) This is a PATCH. * fix: put attach_file markdown on new line (#512) This is a PATCH PR. * docs: fix incorrect value for 'relative' option to Split (#511) This is a PATCH. * docs: add default keybinding maps available in the help (#506) This is a PATCH change. * feat: enable setting discussion tree options (#509) * docs: add description of `refresh_data` function * fix: only set gitlab filetype in one place * feat: set some useful window options for the discussion tree split This is a PATCH PR. --------- Co-authored-by: Jakub F. Bortlík <jakub.bortlik@proton.me> Co-authored-by: Jonathan Duck <Duckbrain30@gmail.com> Co-authored-by: Kitsios Konstantinos <kitsios.konst@gmail.com> Co-authored-by: Mohammad Akbari <makbari@users.noreply.github.com>
1 parent e29909c commit e4eabaf

9 files changed

Lines changed: 145 additions & 11 deletions

File tree

.github/workflows/go.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ on:
88
- 'cmd/**' # Ignore changes to the Lua code
99
- 'go.sum'
1010
- 'go.mod'
11+
12+
concurrency:
13+
group: pr-${{ github.workflow }}-${{ github.head_ref }}
14+
cancel-in-progress: true
15+
1116
jobs:
1217
go_lint:
1318
name: Lint Go 💅

README.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,84 @@ For a list of all these settings please run `:h gitlab.nvim.configuring-the-plug
122122
The plugin sets up a number of useful keybindings in the special buffers it creates, and some global keybindings as well. Refer to the relevant section of the manual `:h gitlab.nvim.keybindings` for more details.
123123

124124
For more information about each of these commands, and about the APIs in general, run `:h gitlab.nvim.api`
125+
126+
`gitlab.nvim` comes with a set of default `keymaps` for different contexts. You can override any of these in your configuration.
127+
128+
### Global Keymaps
129+
130+
These keymaps are available globally (i.e., in any buffer).
131+
132+
```
133+
g? Open a help popup for local keymaps
134+
glaa Add assignee
135+
glad Delete assignee
136+
glla Add label
137+
glld Delete label
138+
glra Add reviewer
139+
glrd Delete reviewer
140+
glA Approve MR
141+
glR Revoke MR approval
142+
glM Merge the feature branch to the target branch and close MR
143+
glC Create a new MR for currently checked-out feature branch
144+
glc Chose MR for review
145+
glS Start review for the currently checked-out branch
146+
gls Show the editable summary of the MR
147+
glu Copy the URL of the MR to the system clipboard
148+
glo Open the URL of the MR in the default Internet browser
149+
gln Create a note (comment not linked to a specific line)
150+
glp Show the pipeline status
151+
gld Toggle the discussions window
152+
glD Toggle between draft mode and live mode
153+
glP Publish all draft comments/notes
154+
```
155+
156+
#### Popup Keymaps
157+
158+
These `keymaps` are active in the popup windows (e.g., for creating comments, editing the summary, etc.).
159+
160+
```
161+
<Tab> Cycle to the next field
162+
<S-Tab> Cycle to the previous field
163+
ZZ Perform action (e.g., save comment)
164+
ZA Perform linewise action
165+
ZQ Discard changes and quit the popup
166+
```
167+
168+
#### Discussion Tree Keymaps
169+
170+
These `keymaps` are active in the discussion tree window.
171+
172+
```
173+
Ea Add an emoji to the note/comment
174+
Ed Remove an emoji from a note/comment
175+
dd Delete comment
176+
e Edit comment
177+
r Reply to comment
178+
- Toggle the resolved status of the whole discussion
179+
o Jump to comment location in file
180+
a Jump to the comment location in the reviewer window
181+
b Jump to the URL of the current note/discussion
182+
u Copy the URL of the current node to clipboard
183+
c Toggle between the notes and discussions views
184+
i Toggle type of discussion tree
185+
P Publish the currently focused note/comment
186+
dt Toggle between date formats
187+
D Toggle between draft mode and live mode
188+
st Toggle whether discussions are sorted by the "latest_reply", or by "original_comment"
189+
t Open or close the discussion
190+
T Open or close separately both resolved and unresolved discussions
191+
R Open or close all resolved discussions
192+
U Open or close all unresolved discussions
193+
<C-R> Refresh the data in the view
194+
<leader>p Print the current node (for debugging)
195+
```
196+
197+
#### Reviewer Keymaps
198+
199+
These `keymaps` are active in the reviewer window (the diff view).
200+
201+
```
202+
c Create a comment for the lines that the following {motion} moves over
203+
s Create a suggestion for the lines that the following {motion} moves over
204+
a Jump to the comment in the discussion tree
205+
```

doc/gitlab.nvim.txt

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,14 +262,20 @@ you call this function with no values the defaults will be used:
262262
keep_current_open = false, -- If true, current discussion stays open even if it should otherwise be closed when toggling
263263
position = "bottom", -- "top", "right", "bottom" or "left"
264264
size = "20%", -- Size of split
265-
relative = "editor", -- Position of tree split relative to "editor" or "window"
265+
relative = "editor", -- Position of tree split relative to "editor" or "win" (window)
266266
resolved = '✓', -- Symbol to show next to resolved discussions
267267
unresolved = '-', -- Symbol to show next to unresolved discussions
268268
unlinked = "󰌸", -- Symbol to show next to unliked comments (i.e., not threads)
269269
draft = "✎", -- Symbol to show next to draft comments/notes
270270
tree_type = "simple", -- Type of discussion tree - "simple" means just list of discussions, "by_file_name" means file tree with discussions under file
271271
draft_mode = false, -- Whether comments are posted as drafts as part of a review
272272
relative_date = true, -- Whether to show relative time like "5 days ago" or absolute time like "03/01/2025 at 01:43"
273+
winopts = { -- Window-local options for the discussion tree split
274+
number = false,
275+
relativenumber = false,
276+
breakindent = true, -- Every wrapped line will continue visually indented
277+
showbreak = "+ ", -- String to put at the start of lines that have been wrapped
278+
}
273279
winbar = nil, -- Custom function to return winbar title, should return a string. Provided with WinbarTable (defined in annotations.lua)
274280
-- If using lualine, please add "gitlab" to disabled file types, otherwise you will not see the winbar.
275281
},
@@ -1078,4 +1084,25 @@ execute and passed the data as an argument.
10781084
with each resource as a key-value pair, with the key being it's
10791085
type.
10801086

1087+
*gitlab.nvim.data*
1088+
gitlab.refresh_data() ~
1089+
1090+
Fetches discussion tree data from Gitlab and refreshes the tree views. It can
1091+
be used in an autocommand to refresh the data every time you enter the
1092+
discussion tree. This exmaple shows how to easily limit the refresh rate to at
1093+
least 10 seconds:
1094+
>lua
1095+
local last_updated = os.time()
1096+
local gitlab = vim.api.nvim_create_augroup("Gitlab", {})
1097+
vim.api.nvim_create_autocmd("BufEnter", {
1098+
group = gitlab,
1099+
callback = function()
1100+
if vim.bo.filetype == "gitlab" and os.time() - last_updated > 10 then
1101+
require("gitlab").refresh_data()
1102+
last_updated = os.time()
1103+
end
1104+
end
1105+
})
1106+
<
1107+
10811108
vim:tw=78:ts=4:sw=4:expandtab:ft=help:norl:

lua/gitlab/actions/common.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ M.switch_can_edit_bufs = function(bool, ...)
2525
---@param v integer
2626
for _, v in ipairs(bufnrs) do
2727
u.switch_can_edit_buf(v, bool)
28-
vim.api.nvim_set_option_value("filetype", "gitlab", { buf = v })
2928
end
3029
end
3130

lua/gitlab/actions/discussions/init.lua

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,19 @@ M.open = function(callback, view_type)
115115
M.linked_bufnr = linked_bufnr
116116
M.unlinked_bufnr = unlinked_bufnr
117117

118-
vim.api.nvim_set_option_value("filetype", "gitlab", { buf = M.split.bufnr })
119-
vim.api.nvim_set_option_value("filetype", "gitlab", { buf = M.unlinked_bufnr })
118+
for opt, val in pairs(state.settings.discussion_tree.winopts) do
119+
vim.api.nvim_set_option_value(opt, val, { win = M.split.winid })
120+
end
121+
120122
vim.api.nvim_set_option_value("filetype", "gitlab", { buf = M.linked_bufnr })
123+
vim.api.nvim_set_option_value("filetype", "gitlab", { buf = M.unlinked_bufnr })
121124

122125
M.split = split
123126
M.split_visible = true
124127
split:mount()
125128

126129
-- Initialize winbar module with data from buffers
130+
winbar.start_timer()
127131
winbar.set_buffers(M.linked_bufnr, M.unlinked_bufnr)
128132
winbar.switch_view_type(view_type)
129133

@@ -156,6 +160,7 @@ M.close = function()
156160
end
157161
M.split_visible = false
158162
M.discussion_tree = nil
163+
winbar.cleanup_timer()
159164
end
160165

161166
---Move to the discussion tree at the discussion from diagnostic on current line.
@@ -455,7 +460,6 @@ M.rebuild_discussion_tree = function()
455460
M.set_tree_keymaps(discussion_tree, M.linked_bufnr, false)
456461
M.discussion_tree = discussion_tree
457462
common.switch_can_edit_bufs(false, M.linked_bufnr, M.unlinked_bufnr)
458-
vim.api.nvim_set_option_value("filetype", "gitlab", { buf = M.linked_bufnr })
459463
state.discussion_tree.resolved_expanded = false
460464
state.discussion_tree.unresolved_expanded = false
461465
end

lua/gitlab/actions/discussions/winbar.lua

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,21 @@ M.switch_view_type = function(override)
271271
M.update_winbar()
272272
end
273273

274-
-- Set up a timer to update the winbar periodically
275-
local timer = vim.uv.new_timer()
276-
timer:start(0, 100, vim.schedule_wrap(M.update_winbar))
274+
---Set up a timer to update the winbar periodically
275+
M.start_timer = function()
276+
M.cleanup_timer()
277+
---@type nil|uv_timer_t
278+
M.timer = vim.uv.new_timer()
279+
M.timer:start(0, 100, vim.schedule_wrap(M.update_winbar))
280+
end
281+
282+
--Stop and close the timer
283+
M.cleanup_timer = function()
284+
if M.timer ~= nil then
285+
M.timer:stop()
286+
M.timer:close()
287+
M.timer = nil
288+
end
289+
end
277290

278291
return M

lua/gitlab/actions/miscellaneous.lua

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ M.attach_file = function()
2727
local body = { file_path = full_path, file_name = choice }
2828
job.run_job("/attachment", "POST", body, function(data)
2929
local markdown = data.markdown
30-
local current_line = u.get_current_line_number()
31-
local bufnr = vim.api.nvim_get_current_buf()
32-
vim.api.nvim_buf_set_lines(bufnr, current_line - 1, current_line, false, { markdown })
30+
vim.api.nvim_put({ markdown }, "l", true, false)
3331
end)
3432
end)
3533
end

lua/gitlab/reviewer/init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ M.open = function()
7878
local on_diffview_closed = function(view)
7979
if view.tabpage == M.tabnr then
8080
M.tabnr = nil
81+
require("gitlab.actions.discussions.winbar").cleanup_timer()
8182
end
8283
end
8384
require("diffview.config").user_emitter:on("view_closed", function(_, args)

lua/gitlab/state.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@ M.settings = {
172172
tree_type = "simple",
173173
draft_mode = false,
174174
relative_date = true,
175+
winopts = {
176+
number = false,
177+
relativenumber = false,
178+
breakindent = true,
179+
showbreak = "+ ",
180+
},
175181
},
176182
emojis = {
177183
formatter = nil,

0 commit comments

Comments
 (0)