Feat: Add Color Configuration (#82)
This MR adds the ability to customize colors for the discussion tree
This commit is contained in:
committed by
GitHub
parent
6b7e67b325
commit
9742b5b229
@@ -133,6 +133,13 @@ require("gitlab").setup({
|
|||||||
success = "✓",
|
success = "✓",
|
||||||
failed = "",
|
failed = "",
|
||||||
},
|
},
|
||||||
|
colors = {
|
||||||
|
discussion_tree = {
|
||||||
|
username = 'Keyword', -- The highlight group used, for instance 'DiagnosticSignWarn'
|
||||||
|
date = 'Comment',
|
||||||
|
chevron = 'Comment',
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
15
after/syntax/gitlab.vim
Normal file
15
after/syntax/gitlab.vim
Normal file
@@ -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"
|
||||||
@@ -67,6 +67,7 @@ M.toggle = function()
|
|||||||
{ linked_section.bufnr, data.discussions, "No Discussions for this MR" },
|
{ linked_section.bufnr, data.discussions, "No Discussions for this MR" },
|
||||||
{ unlinked_section.bufnr, data.unlinked_discussions, "No Notes (Unlinked Discussions) for this MR" },
|
{ unlinked_section.bufnr, data.unlinked_discussions, "No Notes (Unlinked Discussions) for this MR" },
|
||||||
})
|
})
|
||||||
|
|
||||||
M.switch_can_edit_bufs(false)
|
M.switch_can_edit_bufs(false)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@@ -288,6 +289,7 @@ M.rebuild_discussion_tree = function()
|
|||||||
M.set_tree_keymaps(discussion_tree, M.linked_section_bufnr, false)
|
M.set_tree_keymaps(discussion_tree, M.linked_section_bufnr, false)
|
||||||
M.discussion_tree = discussion_tree
|
M.discussion_tree = discussion_tree
|
||||||
M.switch_can_edit_bufs(false)
|
M.switch_can_edit_bufs(false)
|
||||||
|
vim.api.nvim_buf_set_option(M.linked_section_bufnr, "filetype", "gitlab")
|
||||||
end
|
end
|
||||||
|
|
||||||
M.rebuild_unlinked_discussion_tree = function()
|
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.set_tree_keymaps(unlinked_discussion_tree, M.unlinked_section_bufnr, true)
|
||||||
M.unlinked_discussion_tree = unlinked_discussion_tree
|
M.unlinked_discussion_tree = unlinked_discussion_tree
|
||||||
M.switch_can_edit_bufs(false)
|
M.switch_can_edit_bufs(false)
|
||||||
|
vim.api.nvim_buf_set_option(M.unlinked_section_bufnr, "filetype", "gitlab")
|
||||||
end
|
end
|
||||||
|
|
||||||
M.switch_can_edit_bufs = function(bool)
|
M.switch_can_edit_bufs = function(bool)
|
||||||
|
|||||||
9
lua/gitlab/colors.lua
Normal file
9
lua/gitlab/colors.lua
Normal file
@@ -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))
|
||||||
@@ -23,6 +23,7 @@ return {
|
|||||||
server.build() -- Builds the Go binary if it doesn't exist
|
server.build() -- Builds the Go binary if it doesn't exist
|
||||||
state.setPluginConfiguration() -- Sets configuration from `.gitlab.nvim` file
|
state.setPluginConfiguration() -- Sets configuration from `.gitlab.nvim` file
|
||||||
state.merge_settings(args) -- Sets keymaps and other settings from setup function
|
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)
|
reviewer.init() -- Picks and initializes reviewer (default is Delta)
|
||||||
u.has_reviewer(args.reviewer or "delta")
|
u.has_reviewer(args.reviewer or "delta")
|
||||||
end,
|
end,
|
||||||
|
|||||||
@@ -59,6 +59,13 @@ M.settings = {
|
|||||||
},
|
},
|
||||||
go_server_running = false,
|
go_server_running = false,
|
||||||
is_gitlab_project = false,
|
is_gitlab_project = false,
|
||||||
|
colors = {
|
||||||
|
discussion_tree = {
|
||||||
|
username = "Keyword",
|
||||||
|
date = "Comment",
|
||||||
|
chevron = "Comment",
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Merges user settings into the default settings, overriding them
|
-- Merges user settings into the default settings, overriding them
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
local Job = require("plenary.job")
|
local Job = require("plenary.job")
|
||||||
local M = {}
|
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()
|
M.get_current_line_number = function()
|
||||||
return vim.api.nvim_call_function("line", { "." })
|
return vim.api.nvim_call_function("line", { "." })
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user