nvim: make diffview toggleable

This commit is contained in:
Maciej Jur 2024-01-26 00:27:12 +01:00
parent 26e0c95b78
commit ca90017b85
Signed by: kamov
GPG key ID: 191CBFF5F72ECAFD

View file

@ -162,9 +162,20 @@ return {
'nvim-tree/nvim-web-devicons',
},
config = function()
n '<Leader>gd' ':DiffviewOpen<CR>' 'Git: Diff'
n '<Leader>gc' ':DiffviewClose<CR>' 'Git: Close'
n '<Leader>gh' ':DiffviewFileHistory<CR>' 'Git: History'
local lib = require 'diffview.lib'
local function toggle(name)
return function()
if not next(lib.views) then
vim.cmd(name)
else
vim.cmd 'DiffviewClose'
end
end
end
n '<Leader>gd' (toggle 'DiffviewOpen') 'Git: Diff'
n '<Leader>gh' (toggle 'DiffviewFileHistory') 'Git: History'
end
},