Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blame in gitsigns not visible when using cursorline #60

Open
enniomara opened this issue Oct 19, 2021 · 5 comments
Open

Blame in gitsigns not visible when using cursorline #60

enniomara opened this issue Oct 19, 2021 · 5 comments

Comments

@enniomara
Copy link

The current-line blame feature of Gitsigns is not visible when cursorline is on. Even with cursorline off, it's very hard to read. In gitsigns that text has a highlight group of GitSignsCurrentLineBlame.

Using cursorline:
image

No cursorline:
image

I can push a PR but I'm not sure what to set the colors to.

@shaunsingh
Copy link
Owner

Looks like the git blame color is a bit darker then I would like it to be, and the cursorline can likely be a bit darker. That should solve both issues.

@freddiehaddad
Copy link
Contributor

freddiehaddad commented Jan 24, 2022

FWIW, I made this change locally. Doubt it's the right solution, but it uses a color that doesn't clash with the background or cursor line.

In the gitsigns plugin, it appears they set the blame text color as NonText. Does that mean anything to the way the theme is defined? Or does this seem like an issue that needs to be fixed in gitsigns?

$ git diff
diff --git a/lua/gitsigns/highlight.lua b/lua/gitsigns/highlight.lua
index 48c89a4..f54dfbc 100644
--- a/lua/gitsigns/highlight.lua
+++ b/lua/gitsigns/highlight.lua
@@ -36,7 +36,8 @@ local hls = {
    GitSignsChangeLn = { 'GitGutterChangeLine', 'SignifyLineChange', 'DiffChange' },
    GitSignsDeleteLn = { 'GitGutterDeleteLine', 'SignifyLineDelete', 'DiffDelete' },

-   GitSignsCurrentLineBlame = { 'NonText' },
+   GitSignsCurrentLineBlame = { 'GitGutterAdd' },
+   -- GitSignsCurrentLineBlame = { 'NonText' },
 }

 local function is_hl_set(hl_name)

@freddiehaddad
Copy link
Contributor

freddiehaddad commented Jan 25, 2022

As a followup to this thread. When configuring gitsigns plugin, you can switch the color that is used for the blame as follows:

Wherever you configure the gitsigns plugin, define a function to handle the formatting of the blame text and in the return value, replace GitSignsCurrentLineBlame with the color you want. In the example below, I used Label.

Label is a global color defined by all themes. Works perfect for me and blends in.

local status_ok, gitsigns = pcall(require, "gitsigns")
if not status_ok then
  vim.notify("gitsigns plugin not found!")
  return
end

local function current_line_blame_formatter(_, blame_info, opts)
  local text
  if blame_info.author == "Not Committed Yet" then
    text = blame_info.author
  else
    local date_time
    if opts.relative_time then
      date_time = require("gitsigns.util").get_relative_time(tonumber(blame_info["author_time"]))
    else
      date_time = os.date("%Y-%m-%d", tonumber(blame_info["author_time"]))
    end

    text = string.format("%s, %s - %s", blame_info.author, date_time, blame_info.summary)
  end
  return {{" " .. text, "Label"}}
end

gitsigns.setup {
  current_line_blame_formatter = current_line_blame_formatter
}

@Kyuuhachi
Copy link

Same happens with cursor over whitespace. CursorLine has guibg=#3B4252, Cursor has gui=reverse, and GitSignsCurrentLineBlame and WhiteSpace both link to NonText which has guifg=#3B4252. Currently working around it by manually doing hi NonText guifg=#4B5262.

@n0x-io
Copy link

n0x-io commented Mar 28, 2022

I poked around to see if chaning the Value of NonText to something like nord.nord3_gui_bright since it will have the same color as for example comments.
I'm not quite sure if this might break something else tho. While looking around I haven't found any visual issues as far as I can tell.

diff --git a/lua/nord/theme.lua b/lua/nord/theme.lua
index d97df03..aadfd40 100644
--- a/lua/nord/theme.lua
+++ b/lua/nord/theme.lua
@@ -96,7 +96,7 @@ theme.loadEditor = function()
                MatchParen = { fg = nord.nord15_gui, bg = nord.none, style = "bold" },
                ModeMsg = { fg = nord.nord4_gui },
                MoreMsg = { fg = nord.nord4_gui },
-               NonText = { fg = nord.nord1_gui },
+               NonText = { fg = nord.nord3_gui_bright },
                Pmenu = { fg = nord.nord4_gui, bg = nord.nord2_gui },
                PmenuSel = { fg = nord.nord4_gui, bg = nord.nord10_gui },
                PmenuSbar = { fg = nord.nord4_gui, bg = nord.nord2_gui },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants