diff --git a/lua/git.lua b/lua/git.lua index 83e8969..217cde1 100644 --- a/lua/git.lua +++ b/lua/git.lua @@ -11,6 +11,12 @@ local function show(buf_id, items, query) end end +-- Deleted files can't be opened, so choosing one stages the deletion instead +local function choose(item) + if vim.uv.fs_stat(item.path) then return MiniPick.default_choose(item) end + vim.fn.system({ 'git', 'add', '--', item.path }) +end + return { status = function() local lines = vim.fn.systemlist('git -c core.quotepath=false status -s -u') @@ -33,6 +39,6 @@ return { end if #items == 0 then return vim.notify('No unstaged changes', vim.log.levels.INFO) end - MiniPick.start({ source = { items = items, name = 'Git Status', show = show } }) + MiniPick.start({ source = { items = items, name = 'Git Status', show = show, choose = choose } }) end, }