1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
-- This file is part of the CodeDiff code diffing tool.
--
-- Copyright (C) 2026 Marko Ivankovic
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU Affero General Public License as published
-- by the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU Affero General Public License for more details.
--
-- You should have received a copy of the GNU Affero General Public License
-- along with this program. If not, see <https://www.gnu.org/licenses/>.
--
-- Dumps Neovim's own diff classification for a two-window `nvim -d` session, as JSON on stdout:
--
-- [{"lines": [...], "subline": [...]}, {"lines": [...], "subline": [...]}] -- [before, after]
--
-- `lines` is every 1-indexed line Neovim marks as part of the change (`diff_hlID` non-zero, i.e.
-- DiffAdd / DiffChange / DiffDelete / DiffText). `subline` is the subset of those lines carrying
-- at least one DiffText column - Neovim's *within-line* highlighting, which is the capability that
-- makes it interesting here and which no `git diff` row in this comparison has.
--
-- Why a Lua driver at all: Neovim's diff result is not written to any stream. It exists only as
-- window state, and `diff_hlID(lnum, col)` is the sole public way to read it back, per line and
-- per column. So the tool has to be driven headless and interrogated from inside.
--
-- `benchmark_other` always invokes this with `-u NONE`, so the measurement reflects Neovim's own
-- shipped defaults rather than whatever `diffopt` a developer happens to have configured. That
-- matters: `diffopt` can change the algorithm (`algorithm:histogram`) and the within-line
-- alignment (`linematch:N`), so a user config would silently make this a measurement of that
-- config instead of of Neovim.
local out =
for window = 1, 2
io.:
vim.