From 01f40e1f42c71785271c58f5d346724b96b960c8 Mon Sep 17 00:00:00 2001 From: Daniil Tsivinsky Date: Wed, 8 Feb 2023 12:19:42 +0300 Subject: [PATCH] neovim(file-tree): add action for unstaging file --- neovim/.config/nvim/after/plugin/file-tree.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/neovim/.config/nvim/after/plugin/file-tree.lua b/neovim/.config/nvim/after/plugin/file-tree.lua index eb83d8c..0d67dc7 100644 --- a/neovim/.config/nvim/after/plugin/file-tree.lua +++ b/neovim/.config/nvim/after/plugin/file-tree.lua @@ -10,6 +10,16 @@ local function git_stage(node) }):start() end +local function git_unstage(node) + local cwd = vim.loop.cwd() + local relative_path = string.gsub(node.absolute_path, cwd .. "/", "") + + Job:new({ + command = "git", + args = { "reset", relative_path }, + }):start() +end + local function git_reset(node) local cwd = vim.loop.cwd() local relative_path = string.gsub(node.absolute_path, cwd .. "/", "") @@ -43,6 +53,7 @@ require("nvim-tree").setup({ list = { { key = "tn", action = "tabnew" }, { key = "gs", action = "git_stage", action_cb = git_stage }, + { key = "gu", action = "git_unstage", action_cb = git_unstage }, { key = "gr", action = "git_reset", action_cb = git_reset }, { key = "l", action = "edit" }, { key = "@", action = "cd" },