nvim: make diffview toggleable
This commit is contained in:
parent
26e0c95b78
commit
ca90017b85
|
@ -162,9 +162,20 @@ return {
|
||||||
'nvim-tree/nvim-web-devicons',
|
'nvim-tree/nvim-web-devicons',
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
n '<Leader>gd' ':DiffviewOpen<CR>' 'Git: Diff'
|
local lib = require 'diffview.lib'
|
||||||
n '<Leader>gc' ':DiffviewClose<CR>' 'Git: Close'
|
|
||||||
n '<Leader>gh' ':DiffviewFileHistory<CR>' 'Git: History'
|
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
|
end
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue