From 9d0a8053a35f245baaaaba727ec62f5f3c7037c9 Mon Sep 17 00:00:00 2001 From: Thore Goll Date: Thu, 16 Nov 2023 08:04:09 +0100 Subject: [PATCH 1/3] Show HEAD as `NeogitBranchHead` in Log Graph In the log graph it's non intuitive where the currently checked out branch is. To make this more customizable for the user, we add the `NeogitBranchHead` highlight group. --- doc/neogit.txt | 1 + lua/neogit/buffers/common.lua | 9 ++++++--- lua/neogit/lib/hl.lua | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/doc/neogit.txt b/doc/neogit.txt index d7f3cc7b0..402c357f0 100644 --- a/doc/neogit.txt +++ b/doc/neogit.txt @@ -200,6 +200,7 @@ exist, they will be created with sensible defaults based on your colorscheme. STATUS BUFFER NeogitBranch Header showing currently checked out branch +NeogitBranchHead Currently checkoued branch (in log graph) NeogitRemote Header showing current branch's remote (if set) NeogitObjectId Object's SHA hash NeogitStash Stash name diff --git a/lua/neogit/buffers/common.lua b/lua/neogit/buffers/common.lua index d714ee6cf..19e070c66 100644 --- a/lua/neogit/buffers/common.lua +++ b/lua/neogit/buffers/common.lua @@ -120,16 +120,19 @@ M.CommitEntry = Component.new(function(commit, args) remote_name, local_name = local_name, remote_name end + local is_head = string.match(commit.ref_name, "HEAD") ~= nil + local branch_highlight = is_head and "NeogitBranchHead" or "NeogitBranch" + if local_name and remote_name and vim.endswith(remote_name, local_name) then local remote = remote_name:match("^([^/]*)/.*$") table.insert(ref, text(remote .. "/", { highlight = "NeogitRemote" })) - table.insert(ref, text(local_name, { highlight = "NeogitBranch" })) + table.insert(ref, text(local_name, { highlight = branch_highlight })) table.insert(ref, text(" ")) else if local_name then table.insert( ref, - text(local_name, { highlight = local_name:match("/") and "NeogitRemote" or "NeogitBranch" }) + text(local_name, { highlight = local_name:match("/") and "NeogitRemote" or branch_highlight }) ) table.insert(ref, text(" ")) end @@ -137,7 +140,7 @@ M.CommitEntry = Component.new(function(commit, args) if remote_name then table.insert( ref, - text(remote_name, { highlight = remote_name:match("/") and "NeogitRemote" or "NeogitBranch" }) + text(remote_name, { highlight = remote_name:match("/") and "NeogitRemote" or branch_highlight }) ) table.insert(ref, text(" ")) end diff --git a/lua/neogit/lib/hl.lua b/lua/neogit/lib/hl.lua index 2b966f893..f53970d4f 100644 --- a/lua/neogit/lib/hl.lua +++ b/lua/neogit/lib/hl.lua @@ -164,6 +164,7 @@ function M.setup() NeogitCommandCodeNormal = { link = "String" }, NeogitCommandCodeError = { link = "Error" }, NeogitBranch = { fg = palette.blue, bold = true }, + NeogitBranchHead = { fg = palette.blue, bold = true, underline = true }, NeogitRemote = { fg = palette.green, bold = true }, NeogitUnmergedInto = { fg = palette.bg_purple, bold = true }, NeogitUnpushedTo = { fg = palette.bg_purple, bold = true }, From 91d422599eb9b70aeb6f1748b60f703f52775f44 Mon Sep 17 00:00:00 2001 From: Thore Goll Date: Fri, 17 Nov 2023 08:41:31 +0100 Subject: [PATCH 2/3] FIX: Don't highlight `origin/HEAD` with `NeogitBranchHead` --- lua/neogit/buffers/common.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/neogit/buffers/common.lua b/lua/neogit/buffers/common.lua index 19e070c66..badb38489 100644 --- a/lua/neogit/buffers/common.lua +++ b/lua/neogit/buffers/common.lua @@ -120,7 +120,7 @@ M.CommitEntry = Component.new(function(commit, args) remote_name, local_name = local_name, remote_name end - local is_head = string.match(commit.ref_name, "HEAD") ~= nil + local is_head = string.match(commit.ref_name, "HEAD %->") ~= nil local branch_highlight = is_head and "NeogitBranchHead" or "NeogitBranch" if local_name and remote_name and vim.endswith(remote_name, local_name) then From be708dbbca233d5fc12fe8a17c43982920958401 Mon Sep 17 00:00:00 2001 From: Thore Goll Date: Mon, 20 Nov 2023 08:09:13 +0100 Subject: [PATCH 3/3] Reformulate highlight groups in docs --- doc/neogit.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/neogit.txt b/doc/neogit.txt index 402c357f0..8cd549819 100644 --- a/doc/neogit.txt +++ b/doc/neogit.txt @@ -199,9 +199,9 @@ these yourself before the plugin loads, that will be respected. If they do not exist, they will be created with sensible defaults based on your colorscheme. STATUS BUFFER -NeogitBranch Header showing currently checked out branch -NeogitBranchHead Currently checkoued branch (in log graph) -NeogitRemote Header showing current branch's remote (if set) +NeogitBranch Local branches +NeogitBranchHead Accent highlight for current HEAD in LogBuffer +NeogitRemote Remote branches NeogitObjectId Object's SHA hash NeogitStash Stash name NeogitFold Folded text highlight