use plenary.job instead of io.popen

This commit is contained in:
2022-03-21 18:28:12 +03:00
parent 01605e5614
commit c5bdaf0365

View File

@@ -1,3 +1,5 @@
local Job = require("plenary.job")
vim.g.nvim_tree_show_icons = { vim.g.nvim_tree_show_icons = {
git = 1, git = 1,
files = 1, files = 1,
@@ -24,15 +26,23 @@ local function git_stage(node)
local cwd = vim.loop.cwd() local cwd = vim.loop.cwd()
local relative_path = string.gsub(node.absolute_path, cwd .. "/", "") local relative_path = string.gsub(node.absolute_path, cwd .. "/", "")
local f = io.popen("git add " .. relative_path, "r") Job
f:close() :new({
command = "git",
args = { "add", relative_path },
})
:start()
end end
local function git_reset(node) local function git_reset(node)
local cwd = vim.loop.cwd() local cwd = vim.loop.cwd()
local relative_path = string.gsub(node.absolute_path, cwd .. "/", "") local relative_path = string.gsub(node.absolute_path, cwd .. "/", "")
local f = io.popen("git reset " .. relative_path, "r") Job
f:close() :new({
command = "git",
args = { "reset", relative_path },
})
:start()
end end
-- TODO: add here keymap for git diff window -- TODO: add here keymap for git diff window