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

[mini.diff] Highlight group for entire changed lines in overlay #1319

Open
2 tasks done
net opened this issue Oct 31, 2024 · 2 comments
Open
2 tasks done

[mini.diff] Highlight group for entire changed lines in overlay #1319

net opened this issue Oct 31, 2024 · 2 comments
Labels
feature-request Request for a feature to existing module mini.diff

Comments

@net
Copy link

net commented Oct 31, 2024

Contributing guidelines

Module(s)

mini.diff

Description

I would like to set up overlay highlights for mini.diff so that it looks like a standard diff: changed lines highlighted red in the source and green in the buffer.

While right now mini.diff has a highlight group MiniDiffOverAdd for added buffer lines, there is no highlight group that spans entire changed buffer lines.

Additionally, setting the MiniDiffOverChange background to None doesn't fall through to the MiniDiffOverContext background, leaving an unaesthetic gap in the context line background.

For reference, this is how I'd like to color mini.diff overlays:

Screenshot 2024-10-31 at 15 16 10

This is how they can be colored right now:

Screenshot 2024-10-31 at 15 17 36
@net net added the feature-request Request for a feature to existing module label Oct 31, 2024
@net net changed the title Highlight group for entire changed lines in overlay [mini.diff] Highlight group for entire changed lines in overlay Oct 31, 2024
@echasnovski
Copy link
Owner

echasnovski commented Oct 31, 2024

Thanks for the suggestion!

The current design is more aligned with how built-in Neovim diff does it (see :h diff). I'll think about possibly a less intrusive way of achieving GitHub like highlighting, but preserving the current one is still a priority.

The best thing to do right now seems to be link MiniDiffOverChange to MiniDiffOverContext (or make it have background with a slightly different shade). So something like this: vim.api.nvim_set_hl(0, 'MiniDiffOverChange', { link = 'MiniDiffOverContext' }).

@net
Copy link
Author

net commented Oct 31, 2024

I think both styles can be supported with these groups:

  • MiniDiffOverAdd – full added line
  • MiniDiffOverDelete – full deleted line
  • MiniDiffOverChange – changed text
  • MiniDiffOverContext – full changed source line (modified to span the full line without gaps)
  • MiniDiffOverChangeLine – full changed buffer line, unstyled by default (new)

If you wanted to support GitHub-style highlighting where the changed text gets a slightly darker red/green background:

  • MiniDiffOverAdd – full added line
  • MiniDiffOverDelete – full deleted line
  • MiniDiffOverChange – changed text
  • MiniDiffOverChangeSource – changed text in source, links to MiniDiffOverChange by default (new)
  • MiniDiffOverChangeBuffer – changed text in buffer, links to MiniDiffOverChange by default (new)
  • MiniDiffOverContext – full changed source line (modified to span the full line without gaps)
  • MiniDiffOverChangeLine – full changed buffer line, unstyled by default (new)

The "Neovim diff" style can still be the default, and anyone who wants a more traditional style will be able to accomplish it by updating the highlight groups.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for a feature to existing module mini.diff
Projects
None yet
Development

No branches or pull requests

2 participants