diffview Nvim
Single tabpage interface for easily cycling through diffs for all modified files for any git rev.
#status / growing
#type / resource
#resource / diffview-nvim
#resource / astro-nvim
#topic / plugin
#media / website
[!info] related notes
diffviewNvim
Overview
在 astroNvim 中实现类似 vscode 的 git differ 的插件
安装配置
1. 创建插件配置文件
在你的 AstroNvim 配置目录中创建一个文件(例如 lua/plugins/diffview.lua):
return {
"sindrets/diffview.nvim",
event = "VeryLazy", -- 懒加载,提升启动速度
cmd = { "DiffviewOpen", "DiffviewClose", "DiffviewToggleFiles", "DiffviewFocusFiles", "DiffviewRefresh", "DiffviewFileHistory" },
dependencies = {
"nvim-tree/nvim-web-devicons",
},
config = function()
require("diffview").setup({
-- 这里可以放入你上面提供的配置参数
-- 如果想使用默认配置,可以留空或只写 setup({})
use_icons = true,
view = {
merge_tool = {
layout = "diff3_horizontal",
disable_diagnostics = true,
},
},
})
end,
}
2. 常用快捷键集成(可选)
AstroNvim 默认提供了一些 Git 快捷键。如果你想让 Diffview 更易用,可以在该文件的 opts 或 config 之后添加快捷键绑定。
-- 在上面的 return 数组中添加 keys 属性
keys = {
{ "<leader>gd", "<cmd>DiffviewOpen<cr>", desc = "Diffview Open" },
{ "<leader>gh", "<cmd>DiffviewFileHistory %<cr>", desc = "Diffview File History" },
},
3. 保存并重启
- 保存文件。
- 重启 Neovim,AstroNvim 会自动检测到新插件并提示安装(或者直接运行
:Lazy查看进度)。 - 安装完成后,你就可以使用
:DiffviewOpen命令了。