From 33a48cd80f8b73459ec6a9f5052c83afaa2eb0f2 Mon Sep 17 00:00:00 2001 From: kiyan42 Date: Thu, 23 Jul 2020 11:16:25 +0200 Subject: [PATCH] open tree on find --- lua/tree.lua | 7 +++++-- plugin/tree.vim | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lua/tree.lua b/lua/tree.lua index fdd86d5d..52f22bb6 100644 --- a/lua/tree.lua +++ b/lua/tree.lua @@ -124,10 +124,13 @@ local function is_file_readable(fname) return true end -function M.find_file() +function M.find_file(with_open) local bufname = api.nvim_buf_get_name(api.nvim_get_current_buf()) if not is_file_readable(bufname) then return end + if with_open then + M.open() + end lib.set_index_and_redraw(bufname) end @@ -158,7 +161,7 @@ end function M.buf_enter() update_root_dir() if vim.g.lua_tree_follow == 1 then - M.find_file() + M.find_file(false) end end diff --git a/plugin/tree.vim b/plugin/tree.vim index 55846582..298d8629 100644 --- a/plugin/tree.vim +++ b/plugin/tree.vim @@ -23,7 +23,7 @@ command! LuaTreeClose lua require'tree'.close() command! LuaTreeToggle lua require'tree'.toggle() command! LuaTreeRefresh lua require'tree'.refresh() command! LuaTreeClipboard lua require'tree'.print_clipboard() -command! LuaTreeFindFile lua require'tree'.find_file() +command! LuaTreeFindFile lua require'tree'.find_file(true) let &cpo = s:save_cpo unlet s:save_cpo