add git keymaps to file tree
This commit is contained in:
@@ -22,6 +22,21 @@ vim.g.nvim_tree_add_trailing = 1
|
||||
vim.g.nvim_tree_indent_markers = 1
|
||||
vim.g.nvim_tree_group_empty = 1
|
||||
|
||||
-- TODO: don't know if these keymaps are working on windows, need to check
|
||||
local function git_stage(node)
|
||||
local cwd = vim.loop.cwd()
|
||||
local relative_path = string.gsub(node.absolute_path, cwd .. "/", "")
|
||||
|
||||
os.execute("git stage " .. relative_path)
|
||||
end
|
||||
local function git_reset(node)
|
||||
local cwd = vim.loop.cwd()
|
||||
local relative_path = string.gsub(node.absolute_path, cwd .. "/", "")
|
||||
|
||||
os.execute("git reset " .. relative_path)
|
||||
end
|
||||
-- TODO: add here keymap for git diff window
|
||||
|
||||
require("nvim-tree").setup({
|
||||
disable_netrw = true,
|
||||
hijack_netrw = true,
|
||||
@@ -39,6 +54,8 @@ require("nvim-tree").setup({
|
||||
mappings = {
|
||||
list = {
|
||||
{ key = "tn", action = "tabnew" },
|
||||
{ key = "gs", action = "git_stage", action_cb = git_stage },
|
||||
{ key = "gr", action = "git restore", action_cb = git_reset },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user