From 94d64dd0fcb196823c9308bad44cb9e9ad3ee6f9 Mon Sep 17 00:00:00 2001 From: c0r73x Date: Wed, 7 Aug 2024 12:21:50 +0200 Subject: [PATCH 1/6] Added posibility to change discussion-tree chevrons --- doc/gitlab.nvim.txt | 1 + lua/gitlab/actions/discussions/tree.lua | 7 ++++--- lua/gitlab/state.lua | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/gitlab.nvim.txt b/doc/gitlab.nvim.txt index 1a5cde20..a54379ea 100644 --- a/doc/gitlab.nvim.txt +++ b/doc/gitlab.nvim.txt @@ -187,6 +187,7 @@ you call this function with no values the defaults will be used: temp_registers = {}, -- List of registers for backing up popup content (see `:h gitlab.nvim.temp-registers`) }, discussion_tree = { -- The discussion tree that holds all comments + chevrons = { " ", " ", " " }, auto_open = true, -- Automatically open when the reviewer is opened switch_view = "S", -- Toggles between the notes and discussions views default_view = "discussions" -- Show "discussions" or "notes" by default diff --git a/lua/gitlab/actions/discussions/tree.lua b/lua/gitlab/actions/discussions/tree.lua index a8954e9a..d4418a9c 100644 --- a/lua/gitlab/actions/discussions/tree.lua +++ b/lua/gitlab/actions/discussions/tree.lua @@ -325,16 +325,17 @@ M.nui_tree_prepare_node = function(node) for i, text in ipairs(texts) do local line = NuiLine() + local closed, open, none = table.unpack(state.settings.discussion_tree.chevrons) - line:append(string.rep(" ", node._depth - 1)) + line:append(string.rep(none, node._depth - 1)) if i == 1 and node:has_children() then - line:append(node:is_expanded() and " " or " ") + line:append(node:is_expanded() and open or closed) if node.icon then line:append(node.icon .. " ", node.icon_hl) end else - line:append(" ") + line:append(none) end line:append(text, node.text_hl) diff --git a/lua/gitlab/state.lua b/lua/gitlab/state.lua index 964aaa04..f0062c5b 100644 --- a/lua/gitlab/state.lua +++ b/lua/gitlab/state.lua @@ -82,6 +82,7 @@ M.settings = { temp_registers = {}, }, discussion_tree = { + chevrons = { " ", " ", " " }, auto_open = true, switch_view = "S", default_view = "discussions", From db7cf022ff2e22abdc3e58a0851f163f0634f58a Mon Sep 17 00:00:00 2001 From: c0r73x Date: Wed, 7 Aug 2024 16:38:03 +0200 Subject: [PATCH 2/6] Renamed chevrons to expanders --- doc/gitlab.nvim.txt | 6 +++++- lua/gitlab/actions/discussions/tree.lua | 8 ++++---- lua/gitlab/state.lua | 6 +++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/doc/gitlab.nvim.txt b/doc/gitlab.nvim.txt index a54379ea..2a65cfa0 100644 --- a/doc/gitlab.nvim.txt +++ b/doc/gitlab.nvim.txt @@ -187,7 +187,11 @@ you call this function with no values the defaults will be used: temp_registers = {}, -- List of registers for backing up popup content (see `:h gitlab.nvim.temp-registers`) }, discussion_tree = { -- The discussion tree that holds all comments - chevrons = { " ", " ", " " }, + expanders = { -- Discussion tree icons + expanded = " ", -- Icon for expanded discussion thread + collapsed = " ", -- Icon for collapsed discussion thread + indentation = " ", -- Indentation Icon + }, auto_open = true, -- Automatically open when the reviewer is opened switch_view = "S", -- Toggles between the notes and discussions views default_view = "discussions" -- Show "discussions" or "notes" by default diff --git a/lua/gitlab/actions/discussions/tree.lua b/lua/gitlab/actions/discussions/tree.lua index d4418a9c..0b704ce9 100644 --- a/lua/gitlab/actions/discussions/tree.lua +++ b/lua/gitlab/actions/discussions/tree.lua @@ -325,17 +325,17 @@ M.nui_tree_prepare_node = function(node) for i, text in ipairs(texts) do local line = NuiLine() - local closed, open, none = table.unpack(state.settings.discussion_tree.chevrons) + local expanders = state.settings.discussion_tree.expanders - line:append(string.rep(none, node._depth - 1)) + line:append(string.rep(expanders.indentation, node._depth - 1)) if i == 1 and node:has_children() then - line:append(node:is_expanded() and open or closed) + line:append(node:is_expanded() and expanders.expanded or expanders.collapsed) if node.icon then line:append(node.icon .. " ", node.icon_hl) end else - line:append(none) + line:append(expanders.indentation) end line:append(text, node.text_hl) diff --git a/lua/gitlab/state.lua b/lua/gitlab/state.lua index f0062c5b..81971b20 100644 --- a/lua/gitlab/state.lua +++ b/lua/gitlab/state.lua @@ -82,7 +82,11 @@ M.settings = { temp_registers = {}, }, discussion_tree = { - chevrons = { " ", " ", " " }, + expanders = { + expanded = " ", + collapsed = " ", + indentation = " ", + }, auto_open = true, switch_view = "S", default_view = "discussions", From 8d4a3f74bdfbfb7da8be71d00290af6d3d037432 Mon Sep 17 00:00:00 2001 From: c0r73x Date: Thu, 8 Aug 2024 16:55:03 +0200 Subject: [PATCH 3/6] Changes after review --- after/syntax/gitlab.vim | 31 +++++++++++++++++-------------- lua/gitlab/colors.lua | 10 +++++++++- lua/gitlab/state.lua | 2 +- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/after/syntax/gitlab.vim b/after/syntax/gitlab.vim index ef241470..d7ffb450 100644 --- a/after/syntax/gitlab.vim +++ b/after/syntax/gitlab.vim @@ -2,22 +2,25 @@ if filereadable($VIMRUNTIME . '/syntax/markdown.vim') source $VIMRUNTIME/syntax/markdown.vim endif -syntax match Username "\%([]\)\@<= @\S*" -syntax match Mention "\%([] \)\@ Date: Thu, 8 Aug 2024 11:29:52 -0400 Subject: [PATCH 4/6] Update colors.lua --- lua/gitlab/colors.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/gitlab/colors.lua b/lua/gitlab/colors.lua index 67aa6ed6..df5b850d 100644 --- a/lua/gitlab/colors.lua +++ b/lua/gitlab/colors.lua @@ -15,7 +15,7 @@ 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, "GitlabMention", u.get_colors_for_group(discussion.mention)) 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)) +vim.api.nvim_set_hl(0, "GitlabExpander", u.get_colors_for_group(discussion.expander)) vim.api.nvim_set_hl(0, "GitlabDirectory", u.get_colors_for_group(discussion.directory)) vim.api.nvim_set_hl(0, "GitlabDirectoryIcon", u.get_colors_for_group(discussion.directory_icon)) vim.api.nvim_set_hl(0, "GitlabFileName", u.get_colors_for_group(discussion.file_name)) From d5a0bf168b8949fe1b375bb0bba9ad909088d674 Mon Sep 17 00:00:00 2001 From: "Harrison (Harry) Cramer" <32515581+harrisoncramer@users.noreply.github.com> Date: Thu, 8 Aug 2024 11:31:59 -0400 Subject: [PATCH 5/6] Update gitlab.nvim.txt --- doc/gitlab.nvim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/gitlab.nvim.txt b/doc/gitlab.nvim.txt index 2a65cfa0..9bb69c9b 100644 --- a/doc/gitlab.nvim.txt +++ b/doc/gitlab.nvim.txt @@ -290,7 +290,7 @@ you call this function with no values the defaults will be used: username = "Keyword", mention = "WarningMsg", date = "Comment", - chevron = "DiffviewNonText", + expander = "DiffviewNonText", directory = "Directory", directory_icon = "DiffviewFolderSign", file_name = "Normal", From 927fc510527e001bf24a0837ebfa65d1ba11f379 Mon Sep 17 00:00:00 2001 From: "Harrison (Harry) Cramer" <32515581+harrisoncramer@users.noreply.github.com> Date: Thu, 8 Aug 2024 11:33:59 -0400 Subject: [PATCH 6/6] Update colors.lua --- lua/gitlab/colors.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/gitlab/colors.lua b/lua/gitlab/colors.lua index df5b850d..36b0b00a 100644 --- a/lua/gitlab/colors.lua +++ b/lua/gitlab/colors.lua @@ -7,9 +7,9 @@ local colors = state.settings.colors local expanders = state.settings.discussion_tree.expanders vim.g.gitlab_discussion_tree_expander_open = expanders.expanded vim.g.gitlab_discussion_tree_expander_closed = expanders.collapsed -vim.g.gitlab_discussion_tree_draft = '' -vim.g.gitlab_discussion_tree_resolved = '✓' -vim.g.gitlab_discussion_tree_unresolved = '-' +vim.g.gitlab_discussion_tree_draft = "" +vim.g.gitlab_discussion_tree_resolved = "✓" +vim.g.gitlab_discussion_tree_unresolved = "-" local discussion = colors.discussion_tree vim.api.nvim_set_hl(0, "GitlabUsername", u.get_colors_for_group(discussion.username))