Files
neovim/runtime/pack/dist/opt/nvim.difftool/plugin/difftool.lua
Tomas Slusny fec02ae8e4 feat(plugins): nvim.difftool can compare directories #35448
Problem:
Built-in diff mode (nvim -d) does not support directory diffing
as required by git difftool -d. This makes it difficult to compare
entire directories, detect renames, and navigate changes efficiently.

Solution:
Add a DiffTool plugin and command that enables side-by-side diffing of
files and directories in Neovim. The plugin supports rename detection,
highlights changes in the quickfix list, and provides a user command for
easy invocation. This allows proper integration with git difftool -d for
directory comparison.

Example git config:

```ini
[diff]
    tool = nvim_difftool

[difftool "nvim_difftool"]
    cmd = nvim -c "packadd nvim.difftool" -c "DiffTool $LOCAL $REMOTE"
```

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
Co-authored-by: Phạm Bình An <111893501+brianhuster@users.noreply.github.com>
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2025-10-11 19:24:39 -07:00

13 lines
351 B
Lua

if vim.g.loaded_difftool ~= nil then
return
end
vim.g.loaded_difftool = true
vim.api.nvim_create_user_command('DiffTool', function(opts)
if #opts.fargs == 2 then
require('difftool').open(opts.fargs[1], opts.fargs[2])
else
vim.notify('Usage: DiffTool <left> <right>', vim.log.levels.ERROR)
end
end, { nargs = '*', complete = 'file' })