chore: simplify
This commit is contained in:
7 files changed
+49
-137
No files matched your search
@@ -11,6 +11,13 @@ local function show(buf_id, items, query)
|
||||
end
|
||||
end
|
||||
|
||||
-- Diff current file against the index (staged version)
|
||||
local function diff()
|
||||
vim.cmd.diffthis()
|
||||
vim.cmd('vert Git show :./%')
|
||||
vim.cmd.diffthis()
|
||||
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
|
||||
@@ -18,6 +25,7 @@ local function choose(item)
|
||||
end
|
||||
|
||||
return {
|
||||
diff = diff,
|
||||
status = function()
|
||||
local lines = vim.fn.systemlist('git -c core.quotepath=false status -s -u')
|
||||
if vim.v.shell_error ~= 0 then
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
local function open(cmd)
|
||||
local lines = vim.o.lines - vim.o.cmdheight - (vim.o.laststatus > 0 and 1 or 0)
|
||||
local w, h = math.floor(vim.o.columns * 0.95), math.floor(lines * 0.95)
|
||||
local buf = vim.api.nvim_create_buf(false, true)
|
||||
vim.bo[buf].bufhidden = 'wipe'
|
||||
|
||||
local win = vim.api.nvim_open_win(buf, true, {
|
||||
relative = 'editor',
|
||||
width = w,
|
||||
height = h,
|
||||
row = math.floor((lines - h) / 2),
|
||||
col = math.floor((vim.o.columns - w) / 2),
|
||||
})
|
||||
|
||||
vim.fn.jobstart(cmd, { term = true, on_exit = function() pcall(vim.api.nvim_win_close, win, true) end })
|
||||
end
|
||||
|
||||
return { open = open }
|
||||
Reference in new issue
Block a user