From c5bdaf03651c75e9d2e6dfc3caedbc34f510c36c Mon Sep 17 00:00:00 2001 From: Daniil Tsivinsky Date: Mon, 21 Mar 2022 18:28:12 +0300 Subject: [PATCH] use plenary.job instead of io.popen --- neovim/.config/nvim/lua/user/file-tree.lua | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/neovim/.config/nvim/lua/user/file-tree.lua b/neovim/.config/nvim/lua/user/file-tree.lua index 0ecf4da..7cd6c17 100644 --- a/neovim/.config/nvim/lua/user/file-tree.lua +++ b/neovim/.config/nvim/lua/user/file-tree.lua @@ -1,3 +1,5 @@ +local Job = require("plenary.job") + vim.g.nvim_tree_show_icons = { git = 1, files = 1, @@ -24,15 +26,23 @@ local function git_stage(node) local cwd = vim.loop.cwd() local relative_path = string.gsub(node.absolute_path, cwd .. "/", "") - local f = io.popen("git add " .. relative_path, "r") - f:close() + Job + :new({ + command = "git", + args = { "add", relative_path }, + }) + :start() end local function git_reset(node) local cwd = vim.loop.cwd() local relative_path = string.gsub(node.absolute_path, cwd .. "/", "") - local f = io.popen("git reset " .. relative_path, "r") - f:close() + Job + :new({ + command = "git", + args = { "reset", relative_path }, + }) + :start() end -- TODO: add here keymap for git diff window