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

Make virtual text background transparent #146

Open
sinharaksh1t opened this issue Nov 28, 2024 · 2 comments
Open

Make virtual text background transparent #146

sinharaksh1t opened this issue Nov 28, 2024 · 2 comments

Comments

@sinharaksh1t
Copy link

Hello, I'm not sure if this is a property of the vim virtual text or the property of the plugin's virtual text highlight group or perhaps the property of the color scheme (tokyonight-night) that I'm using, but somehow the virtual text for git-blame that I see on my neovim is a bit odd. I have the vim cursorline enabled so when the virtual text appears for the blame, I see a darkened background for the text as seen in the screenshot below.

image

I have also tried using highlight_group = "Comment" but it makes no difference to this specific concern:

image

If you look at the lines with comments in the above 2 screenshots, this issue is not seen (the line that says Show which line your cursor is on). Is it possible to have a transparent background effect on the blame virtual text? Or do you have some other advice to deal with this?

I'm using the following options:

opts = {
    enabled = true,
    message_template = " <author> • <date> • <summary> • <<sha>>",
    date_format = "%b-%d-%Y", 
    virtual_text_column = 80, 
    message_when_not_committed = "Not committed yet",
    display_virtual_text = 1,
    highlight_group = "Question",
}
@gauthier-th
Copy link

gauthier-th commented Dec 11, 2024

You can do something like that to define a new highlight, with the CursorLine background and the Comment foreground, and use this highlight with git-blame:

    opts = function()
      local hl_cursor_line = vim.api.nvim_get_hl(0, { name = "CursorLine" })
      local hl_comment = vim.api.nvim_get_hl(0, { name = "Comment" })
      local hl_combined = vim.tbl_extend("force", hl_comment, { bg = hl_cursor_line.bg })
      vim.api.nvim_set_hl(0, "CursorLineBlame", hl_combined)
      return {
        enabled = true,
        highlight_group = "CursorLineBlame",
        -- etc.
      }
    end,

@sinharaksh1t
Copy link
Author

@gauthier-th super cool! After looking at the code I can understand what you did and that's so smart yet so simple. I don't think I could've come up with that myself. Thanks for the answer!

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

2 participants