Skip to content

Commit

Permalink
Showing 7 changed files with 48 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -133,6 +133,13 @@ require("gitlab").setup({
success = "",
failed = "",
},
colors = {
discussion_tree = {
username = 'Keyword', -- The highlight group used, for instance 'DiagnosticSignWarn'
date = 'Comment',
chevron = 'Comment',
}
}
})
```

15 changes: 15 additions & 0 deletions after/syntax/gitlab.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
if filereadable($VIMRUNTIME . '/syntax/markdown.vim')
source $VIMRUNTIME/syntax/markdown.vim
endif

syntax match Username "@\w\+"
syntax match Date "\v\d+\s+\w+\s+ago"
syntax match ChevronDown ""
syntax match ChevronRight ""

highlight link Username GitlabUsername
highlight link Date GitlabDate
highlight link ChevronDown GitlabChevron
highlight link ChevronRight GitlabChevron

let b:current_syntax = "gitlab"
3 changes: 3 additions & 0 deletions lua/gitlab/actions/discussions.lua
Original file line number Diff line number Diff line change
@@ -67,6 +67,7 @@ M.toggle = function()
{ linked_section.bufnr, data.discussions, "No Discussions for this MR" },
{ unlinked_section.bufnr, data.unlinked_discussions, "No Notes (Unlinked Discussions) for this MR" },
})

M.switch_can_edit_bufs(false)
end)
end
@@ -288,6 +289,7 @@ M.rebuild_discussion_tree = function()
M.set_tree_keymaps(discussion_tree, M.linked_section_bufnr, false)
M.discussion_tree = discussion_tree
M.switch_can_edit_bufs(false)
vim.api.nvim_buf_set_option(M.linked_section_bufnr, "filetype", "gitlab")
end

M.rebuild_unlinked_discussion_tree = function()
@@ -299,6 +301,7 @@ M.rebuild_unlinked_discussion_tree = function()
M.set_tree_keymaps(unlinked_discussion_tree, M.unlinked_section_bufnr, true)
M.unlinked_discussion_tree = unlinked_discussion_tree
M.switch_can_edit_bufs(false)
vim.api.nvim_buf_set_option(M.unlinked_section_bufnr, "filetype", "gitlab")
end

M.switch_can_edit_bufs = function(bool)
9 changes: 9 additions & 0 deletions lua/gitlab/colors.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
local state = require("gitlab.state")
local u = require("gitlab.utils")

local colors = state.settings.colors
local discussion = colors.discussion_tree

vim.api.nvim_set_hl(0, "GitlabUsername", u.get_colors_for_group(discussion.username))
vim.api.nvim_set_hl(0, "GitlabDate", u.get_colors_for_group(discussion.date))
vim.api.nvim_set_hl(0, "GitlabChevron", u.get_colors_for_group(discussion.chevron))
1 change: 1 addition & 0 deletions lua/gitlab/init.lua
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ return {
server.build() -- Builds the Go binary if it doesn't exist
state.setPluginConfiguration() -- Sets configuration from `.gitlab.nvim` file
state.merge_settings(args) -- Sets keymaps and other settings from setup function
require("gitlab.colors") -- Sets colors
reviewer.init() -- Picks and initializes reviewer (default is Delta)
u.has_reviewer(args.reviewer or "delta")
end,
7 changes: 7 additions & 0 deletions lua/gitlab/state.lua
Original file line number Diff line number Diff line change
@@ -59,6 +59,13 @@ M.settings = {
},
go_server_running = false,
is_gitlab_project = false,
colors = {
discussion_tree = {
username = "Keyword",
date = "Comment",
chevron = "Comment",
},
},
}

-- Merges user settings into the default settings, overriding them
6 changes: 6 additions & 0 deletions lua/gitlab/utils/init.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
local Job = require("plenary.job")
local M = {}

M.get_colors_for_group = function(group)
local normal_fg = vim.fn.synIDattr(vim.fn.hlID(group), "fg")
local normal_bg = vim.fn.synIDattr(vim.fn.hlID(group), "bg")
return { fg = normal_fg, bg = normal_bg }
end

M.get_current_line_number = function()
return vim.api.nvim_call_function("line", { "." })
end

0 comments on commit 9742b5b

Please sign in to comment.