Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions doc/gitlab.nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,12 @@ you call this function with no values the defaults will be used:
tree_type = "simple", -- Type of discussion tree - "simple" means just list of discussions, "by_file_name" means file tree with discussions under file
draft_mode = false, -- Whether comments are posted as drafts as part of a review
relative_date = true, -- Whether to show relative time like "5 days ago" or absolute time like "03/01/2025 at 01:43"
winopts = { -- Window-local options for the discussion tree split
number = false,
relativenumber = false,
breakindent = true, -- Every wrapped line will continue visually indented
showbreak = "+ ", -- String to put at the start of lines that have been wrapped
}
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.
},
Expand Down Expand Up @@ -1078,4 +1084,25 @@ execute and passed the data as an argument.
with each resource as a key-value pair, with the key being it's
type.

*gitlab.nvim.data*
gitlab.refresh_data() ~

Fetches discussion tree data from Gitlab and refreshes the tree views. It can
be used in an autocommand to refresh the data every time you enter the
discussion tree. This exmaple shows how to easily limit the refresh rate to at
least 10 seconds:
>lua
local last_updated = os.time()
local gitlab = vim.api.nvim_create_augroup("Gitlab", {})
vim.api.nvim_create_autocmd("BufEnter", {
group = gitlab,
callback = function()
if vim.bo.filetype == "gitlab" and os.time() - last_updated > 10 then
require("gitlab").refresh_data()
last_updated = os.time()
end
end
})
<

vim:tw=78:ts=4:sw=4:expandtab:ft=help:norl:
1 change: 0 additions & 1 deletion lua/gitlab/actions/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ M.switch_can_edit_bufs = function(bool, ...)
---@param v integer
for _, v in ipairs(bufnrs) do
u.switch_can_edit_buf(v, bool)
vim.api.nvim_set_option_value("filetype", "gitlab", { buf = v })
end
end

Expand Down
8 changes: 5 additions & 3 deletions lua/gitlab/actions/discussions/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,12 @@ M.open = function(callback, view_type)
M.linked_bufnr = linked_bufnr
M.unlinked_bufnr = unlinked_bufnr

vim.api.nvim_set_option_value("filetype", "gitlab", { buf = M.split.bufnr })
vim.api.nvim_set_option_value("filetype", "gitlab", { buf = M.unlinked_bufnr })
for opt, val in pairs(state.settings.discussion_tree.winopts) do
vim.api.nvim_set_option_value(opt, val, { win = M.split.winid })
end

vim.api.nvim_set_option_value("filetype", "gitlab", { buf = M.linked_bufnr })
vim.api.nvim_set_option_value("filetype", "gitlab", { buf = M.unlinked_bufnr })

M.split = split
M.split_visible = true
Expand Down Expand Up @@ -455,7 +458,6 @@ M.rebuild_discussion_tree = function()
M.set_tree_keymaps(discussion_tree, M.linked_bufnr, false)
M.discussion_tree = discussion_tree
common.switch_can_edit_bufs(false, M.linked_bufnr, M.unlinked_bufnr)
vim.api.nvim_set_option_value("filetype", "gitlab", { buf = M.linked_bufnr })
state.discussion_tree.resolved_expanded = false
state.discussion_tree.unresolved_expanded = false
end
Expand Down
6 changes: 6 additions & 0 deletions lua/gitlab/state.lua
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ M.settings = {
tree_type = "simple",
draft_mode = false,
relative_date = true,
winopts = {
number = false,
relativenumber = false,
breakindent = true,
showbreak = "+ ",
},
},
emojis = {
formatter = nil,
Expand Down
Loading