Add config option to follow buffer directory

This commit is contained in:
Akin Sowemimo 2020-05-18 22:00:43 +01:00 committed by kiyan42
parent 5fcbc21edb
commit 9201d123fd
2 changed files with 11 additions and 6 deletions

View File

@ -153,6 +153,15 @@ function M.check_windows_and_close()
end end
end end
function M.navigate_to_buffer_dir(bufname)
local new_path = get_cwd()
if new_path ~= '/' then
new_path = new_path .. '/'
end
set_root_path(new_path)
init_tree()
end
function M.check_buffer_and_open() function M.check_buffer_and_open()
local bufname = api.nvim_buf_get_name(0) local bufname = api.nvim_buf_get_name(0)
if bufname == '' then if bufname == '' then
@ -169,12 +178,7 @@ function M.check_buffer_and_open()
M.toggle() M.toggle()
else else
local new_path = get_cwd() M.navigate_to_buffer_dir()
if new_path ~= '/' then
new_path = new_path .. '/'
end
set_root_path(new_path)
init_tree()
end end
end end

View File

@ -23,6 +23,7 @@ augroup LuaTree
au BufEnter * :LuaTreeFindFile au BufEnter * :LuaTreeFindFile
endif endif
au BufEnter * lua require'tree'.navigate_to_buffer_dir()
au ColorScheme * lua require'tree'.reset_highlight() au ColorScheme * lua require'tree'.reset_highlight()
augroup end augroup end