From d42e76e3cfd81555a6d7b85db53924aac81f4c40 Mon Sep 17 00:00:00 2001 From: Kristijan Husak Date: Wed, 29 Jul 2020 18:03:27 +0200 Subject: [PATCH] Always focus tree when finding file. --- lua/lib/lib.lua | 4 ++++ lua/tree.lua | 1 + 2 files changed, 5 insertions(+) diff --git a/lua/lib/lib.lua b/lua/lib/lib.lua index 118e9c37..9fd095d9 100644 --- a/lua/lib/lib.lua +++ b/lua/lib/lib.lua @@ -287,6 +287,10 @@ function M.win_open() return M.Tree.winnr() ~= nil end +function M.win_focus() + api.nvim_set_current_win(M.Tree.winnr()) +end + function M.toggle_ignored() pops.show_ignored = not pops.show_ignored return M.refresh_tree() diff --git a/lua/tree.lua b/lua/tree.lua index ddc60e81..9dd1cd25 100644 --- a/lua/tree.lua +++ b/lua/tree.lua @@ -116,6 +116,7 @@ function M.find_file(with_open) if with_open then M.open() + lib.win_focus() end lib.set_index_and_redraw(bufname) end