From 8bb58daddb013871e161dafa9513afcdccd4d296 Mon Sep 17 00:00:00 2001 From: Matthieu ARENE Date: Sat, 7 Aug 2021 10:02:03 +0200 Subject: [PATCH] Feature: add the possibility to not focus tree on TabEnter when (#545) --- lua/nvim-tree.lua | 2 +- lua/nvim-tree/view.lua | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index c379a3c8..4e52b2ae 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -46,7 +46,7 @@ function M.tab_change() if bufname:match("Neogit") ~= nil or bufname:match("--graph") ~= nil then return end - view.open() + view.open({ focus_tree = false }) end end) end diff --git a/lua/nvim-tree/view.lua b/lua/nvim-tree/view.lua index b05d30cc..c2889b86 100644 --- a/lua/nvim-tree/view.lua +++ b/lua/nvim-tree/view.lua @@ -264,7 +264,8 @@ local function set_local(opt, value) vim.cmd(cmd) end -function M.open() +function M.open(options) + options = options or { focus_tree = true } if not is_buf_valid() then M.setup() end @@ -282,6 +283,9 @@ function M.open() set_local(k, v) end vim.cmd ":wincmd =" + if not options.focus_tree then + vim.cmd("wincmd p") + end end function M.close()