Skip to content

[Bug] Can't get character level highlighting working #205

@xstoicunicornx

Description

@xstoicunicornx

Description

Firstly, thank you for this fork! Love having the diff1_inline view.

Secondly, this is very low priority issue.

I've been trying to get the character level highlighting mentioned in TIPS.md working in unified diff1_inline view but haven't been successful. Is seems like it doesn't work with tokyonight theme? Are there specific highlights I need to set to get it working?

It is working in diff2 views. Is it possible to apply the same background highlights to the diff1_inline unified view? Even when diff1_inline unified view is working it only does foreground highlights, it would be nice to be able to do background instead.

Expected behavior

character level diff highlighting works

Actual behavior

character level diff highlighting does not work, only line level is working.

Steps to reproduce

  1. nvim --clean -u mini.lua
  2. :DiffviewOpen (or :DiffviewFileHistory)

Health check

Output of :checkhealth diffview

diffview:                                                                 3 ⚠️

Checking plugin dependencies ~
- ✅ OK nvim-web-devicons installed.
- ⚠️ WARNING Optional dependency 'mini.icons' not found.

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


Log info

Relevant info from :DiffviewLog
############################
### PUT LOG CONTENT HERE ###
############################

Neovim version

NVIM v0.11.5
Build type: Release
LuaJIT 2.1.1765007043
Run "nvim -V1 -v" for more info

Operating system and version

macOS 15.7.7 24G720 arm64

Minimal config

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/dlyongemallo/diffview.nvim.git" },
	-- ##################################################################
	-- ### ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE ###
	-- ##################################################################
	{ "diffchar.vim",      url = "https://github.com/rickhowe/diffchar.vim.git" },
	{ "tokyonight.nvim",   url = "https://github.com/folke/tokyonight.nvim.git" }
}

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("diffview").setup({
	-- ##############################################################################
	-- ### ADD DIFFVIEW.NVIM CONFIG THAT IS _NECESSARY_ FOR REPRODUCING THE ISSUE ###
	-- ##############################################################################
	enhanced_diff_hl = true,
	view = {
		default = { layout = "diff1_inline" },
		inline = {
			deletion_highlight = "full_width",
			style = "unified",
		},
		file_history_view = { layout = "diff1_inline" },
		cycle_layouts = {
			default = { "diff1_inline", "diff2_horizontal", },
		},
	}

})

vim.opt.termguicolors = true
vim.cmd("colorscheme tokyonight")

-- ############################################################################
-- ### ADD INIT.LUA SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE ###
-- ############################################################################

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