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

Added curhl to change the cursorline highlight for signs #1048

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion lua/gitsigns/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
--- @field hl string
--- @field text string
--- @field numhl string
--- @field curhl string
--- @field linehl string

--- @alias Gitsigns.SignType
Expand Down Expand Up @@ -188,36 +189,47 @@ M.schema = {
type = 'table',
deep_extend = true,
default = {
add = { hl = 'GitSignsAdd', text = '┃', numhl = 'GitSignsAddNr', linehl = 'GitSignsAddLn' },
add = {
hl = 'GitSignsAdd',
text = '┃',
numhl = 'GitSignsAddNr',
linehl = 'GitSignsAddLn',
curhl = 'GitSignsAdd',
},
change = {
hl = 'GitSignsChange',
text = '┃',
numhl = 'GitSignsChangeNr',
linehl = 'GitSignsChangeLn',
curhl = 'GitSignsChange',
Copy link
Owner

@lewis6991 lewis6991 Jun 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs its own unique highlight group which is cleared by default. Highlight groups are managed in highlights.lua.

Then you need to run make to update the documentation.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Everything is handled by neovim internally in nvim_buf_set_extmark, that's why i think it's pointless to add a default for it, if cursorline_hl_group is not specified it will use the default highlight specified for the extmark (like it was before this change). If it's specified it will use that group.

                  • cursorline_hl_group: name of the highlight group used to
                    highlight the sign column text when the cursor is on the
                    same line as the mark and 'cursorline' is enabled.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extmarks are an implementation choice. They have nothing to do with the API gitsigns exposes. All highlights that Gitsigns uses are defined and documented. Eventually I'm going to remove these from the configuration in setup().

Any I wasted enough time on this so closing.

},
delete = {
hl = 'GitSignsDelete',
text = '▁',
numhl = 'GitSignsDeleteNr',
linehl = 'GitSignsDeleteLn',
curhl = 'GitSignsDelete',
},
topdelete = {
hl = 'GitSignsTopdelete',
text = '▔',
numhl = 'GitSignsTopdeleteNr',
linehl = 'GitSignsTopdeleteLn',
curhl = 'GitSignsTopdelete',
},
changedelete = {
hl = 'GitSignsChangedelete',
text = '~',
numhl = 'GitSignsChangedeleteNr',
linehl = 'GitSignsChangedeleteLn',
curhl = 'GitSignsChangedelete',
},
untracked = {
hl = 'GitSignsUntracked',
text = '┆',
numhl = 'GitSignsUntrackedNr',
linehl = 'GitSignsUntrackedLn',
curhl = 'GitSignsUntracked',
},
},
default_help = [[{
Expand Down Expand Up @@ -253,30 +265,35 @@ M.schema = {
text = '┃',
numhl = 'GitSignsStagedAddNr',
linehl = 'GitSignsStagedAddLn',
curhl = 'GitSignsStagedAdd',
},
change = {
hl = 'GitSignsStagedChange',
text = '┃',
numhl = 'GitSignsStagedChangeNr',
linehl = 'GitSignsStagedChangeLn',
curhl = 'GitSignsStagedChange',
},
delete = {
hl = 'GitSignsStagedDelete',
text = '▁',
numhl = 'GitSignsStagedDeleteNr',
linehl = 'GitSignsStagedDeleteLn',
curhl = 'GitSignsStagedDelete',
},
topdelete = {
hl = 'GitSignsStagedTopdelete',
text = '▔',
numhl = 'GitSignsStagedTopdeleteNr',
linehl = 'GitSignsStagedTopdeleteLn',
curhl = 'GitSignsStagedTopdelete',
},
changedelete = {
hl = 'GitSignsStagedChangedelete',
text = '~',
numhl = 'GitSignsStagedChangedeleteNr',
linehl = 'GitSignsStagedChangedeleteLn',
curhl = 'GitSignsStagedChangedelete',
},
},
default_help = [[{
Expand Down
1 change: 1 addition & 0 deletions lua/gitsigns/signs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function M:add(bufnr, signs)
sign_text = config.signcolumn and text or '',
priority = config.sign_priority,
sign_hl_group = hls.hl,
cursorline_hl_group = hls.curhl or nil,
number_hl_group = config.numhl and hls.numhl or nil,
line_hl_group = config.linehl and hls.linehl or nil,
})
Expand Down
Loading