Skip to content

[Bug] DiffviewDiffAddAsDelete overrides custom colorschema #621

Description

@TelpeNight

Description

DiffviewDiffAddAsDelete misses {default = true} attr, so on ColorScheme autocmd Diffview overrides custom setup.

Expected behavior

Diffview respects existing value.

Image

Actual behavior

Diffview rederives hl group from DiffDelete. If DiffDelete is setup to be dim globally (so that manual diffthis would look nicer), this affects DiffAdd with enhanced_diff_hl enabled.

Image

Steps to reproduce

  1. git init
  2. printf 'a1\na2\n' > ./a.txt
  3. git add a.txt
  4. git commit -m 'a.txt'
  5. printf 'a2\n' > ./a.txt
  6. nvim --clean -u mini.lua
  7. :DiffviewOpen
Image

-- diffthis looks pretty
8. printf 'a1\na2\n' > ./b.txt
9.
:e a.txt
:vsplit b.txt
:windo diffthis

Image

Health check

Output of :checkhealth diffview
==============================================================================
diffview:                                                                 1 ⚠️

Checking plugin dependencies ~
- ✅ OK nvim-web-devicons installed.

Checking VCS tools ~
- The plugin requires at least one of the supported VCS tools to be valid.
- ✅ OK Git found.
- ✅ OK Git is up-to-date. (2.50.1)
- ⚠️ WARNING Configured `hg_cmd` is not executable: 'hg'

Log info

No response

Neovim version

NVIM v0.12.5
Build type: Release
LuaJIT 2.1.1787165859

Operating system and version

Darwin 25.6.0 arm64

Minimal config

-- #######################################
-- ### USAGE: nvim --clean -u mini.lua ###
-- #######################################

local root = vim.fn.stdpath("run") .. "/nvim/diffview.nvim"
local plugin_dir = root .. "/plugins"
vim.fn.mkdir(plugin_dir, "p")

for _, name in ipairs({ "config", "data", "state", "cache" }) do
	vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

local plugins = {
	{ "nvim-web-devicons", url = "https://github.com/nvim-tree/nvim-web-devicons.git" },
	{ "diffview.nvim",     url = "https://github.com/sindrets/diffview.nvim.git" },
	{ "catppuccin",        url = "https://github.com/catppuccin/nvim" }
}

for _, spec in ipairs(plugins) do
	local install_path = plugin_dir .. "/" .. spec[1]
	if vim.fn.isdirectory(install_path) ~= 1 then
		if spec.url then
			print(string.format("Installing '%s'...", spec[1]))
			vim.fn.system({ "git", "clone", "--depth=1", spec.url, install_path })
		end
	end
	vim.opt.runtimepath:append(spec.path or install_path)
end

require("catppuccin").setup({
	highlight_overrides = {
		all = function(colors)
			local U = require "catppuccin.utils.colors"
			return {
				DiffviewDiffAddAsDelete = {
					bg = U.darken(colors.red, 0.18, colors.base),
				},
				DiffDelete = {
					bg = "NONE",
					fg = colors.surface1,
				},
			}
		end,
	},

})

require("diffview").setup({
	enhanced_diff_hl = true,
})

vim.opt.termguicolors = true
vim.cmd("colorscheme catppuccin-macchiato")

print("Ready!")

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions