Skip to content

How to setup diff view colorscheme like the one in the readme (the screenshot)? #546

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

Open
gaoxiaoliangz opened this issue Dec 9, 2024 · 10 comments

Comments

@gaoxiaoliangz
Copy link

gaoxiaoliangz commented Dec 9, 2024

I know it's not an issue of the project, but I really can't find any place to discuss this. The diff view in the screen shot looks really cool. Especially the diff color schemes.

vim diff highlight groups are DiffAdd, DiffDelete, DiffChange and DiffText. And I noticed that in the screenshot, the DiffAdd are rendered as red on the left, just like what vscode does. On the right side it's bluish.

Is there any config reference you can provide, so that I can achieve the same diff color scheme?

@jdela22
Copy link

jdela22 commented Dec 14, 2024

I am also curious about the specific values set for the fg/bg of the highlight group. I'm currently setting them in the diff_buf_win_enter hook but cannot get the values to match.

@jdela22
Copy link

jdela22 commented Dec 19, 2024

@gaoxiaoliangz I was able to figure it out. The example in the screenshot is just using the existing hl group provided by the tokyonight theme (I believe the 'night' variation specifically). In my case, I was already using this theme but the hl groups and a few other background-related colors were not showing up right due to my use of tmux. If that's what's happening to you, try disabling tmux and viewing the diff.

@jamesgour
Copy link

Thanks for opening this, I was wondering the same thing. I use gruvbox, but want to figure out how to get those fancy empty line symbols. Mine show up as ugly -----!

@gaoxiaoliangz
Copy link
Author

@jamesgour You can try this vim.opt.fillchars:append("diff:╱")

@jamesgour
Copy link

Thanks @gaoxiaoliangz, that's pretty close! Doesn't look exact on my terminal but maybe it's because I'm using Wezterm :D

@phdah
Copy link

phdah commented Jan 12, 2025

Hey! Based on @jdela22 comments above, I manually changed my colors to follow the tokyonight color schemes for the diff sections in my init.lua:

vim.api.nvim_set_hl(0, "DiffAdd", {bg = "#20303b"})
vim.api.nvim_set_hl(0, "DiffDelete", {bg = "#37222c"})
vim.api.nvim_set_hl(0, "DiffChange", {bg = "#1f2231"})
vim.api.nvim_set_hl(0, "DiffText", {bg = "#394b70"})

Just posting it here as a reference if anyone want to copy paste!

@charbelnicolas
Copy link
Contributor

This is what I have in my highlights configuration:

vim.api.nvim_set_hl(0, 'DiffAdd', { bg = '#34462F' })
vim.api.nvim_set_hl(0, 'DiffDelete', { bg = '#462F2F' })
vim.api.nvim_set_hl(0, 'DiffChange', { bg = '#2F4146' })
vim.api.nvim_set_hl(0, 'DiffText', { bg = '#463C2F' })

vim.api.nvim_set_hl(0, 'DiffAdded', { fg = colors[3], bold = true })
vim.api.nvim_set_hl(0, 'DiffRemoved', { fg = colors[2], bold = true })
vim.api.nvim_set_hl(0, 'DiffChanged', { fg = colors[4], bold = true })

vim.api.nvim_set_hl(0, 'DiffviewWinSeparator', { fg = colors[9] })
vim.api.nvim_set_hl(0, 'DiffviewDiffDelete', { fg = colors[9] })
vim.api.nvim_set_hl(0, 'DiffviewFilePanelSelected', { fg = colors[6] })

vim.api.nvim_set_hl(0, 'DiffviewStatusAdded', { fg = colors[3], bold = true })
vim.api.nvim_set_hl(0, 'DiffviewStatusUntracked', { fg = colors[8], bold = true })
vim.api.nvim_set_hl(0, 'DiffviewStatusModified', { fg = colors[4], bold = true })
vim.api.nvim_set_hl(0, 'DiffviewStatusRenamed', { fg = colors[3], bold = true })
vim.api.nvim_set_hl(0, 'DiffviewStatusDeleted', { fg = colors[2], bold = true })
vim.api.nvim_set_hl(0, 'DiffviewStatusIgnored', { fg = colors[9], bold = true })

@phdah
Copy link

phdah commented Jan 21, 2025

vim.api.nvim_set_hl(0, 'DiffAdd', { bg = '#34462F' })
vim.api.nvim_set_hl(0, 'DiffDelete', { bg = '#462F2F' })
vim.api.nvim_set_hl(0, 'DiffChange', { bg = '#2F4146' })
vim.api.nvim_set_hl(0, 'DiffText', { bg = '#463C2F' })

These are not the colors from the image tho... But also nice.

@JonA02
Copy link

JonA02 commented Feb 18, 2025

I was looking for this exact discussion lol. The whole neovim environment in the screenshot looks so good!

Can someone point to what's being used? i.e. Statusbar, Tabsbar, fonts, theme (judging from the discussion, it seems to be TokyoNight-Night), etc.?

I have diffview installed and running off the supplied configuration in the readme but it looks no where near what it looks like in the screenshot lol. I'm still pretty new to neovim so any pointers would be greatly appreciated!!

Image

feryardiant added a commit to feryardiant/config-nvim that referenced this issue Feb 28, 2025
Based on sindrets/diffview.nvim#546 at the very moment there's no way to
customize the diffs especially in conflicted files. Yes, there's plugin
called https://github.com/akinsho/git-conflict.nvim to help highlighting
conflict blocks but it superseeded by the `diffview.nvim`
@feryardiant
Copy link

Based on these lines

DiffAdd = "DiffAdd",
DiffDelete = "DiffDelete",
DiffChange = "DiffChange",
DiffText = "DiffText",

I believe, it should be possible to customize this way

vim.api.nvim_set_hl(0, 'DiffAdd', { ... })
vim.api.nvim_set_hl(0, 'DiffDelete', { ... })
vim.api.nvim_set_hl(0, 'DiffChange', { ... })
vim.api.nvim_set_hl(0, 'DiffText', { ... })

or you might try

vim.api.nvim_set_hl(0, 'DiffviewDiffAdd', { ... })
vim.api.nvim_set_hl(0, 'DiffviewDiffDelete', { ... })
vim.api.nvim_set_hl(0, 'DiffviewDiffChange', { ... })
vim.api.nvim_set_hl(0, 'DiffviewDiffText', { ... })

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

7 participants