Merge pull request #13 from Akin909/bugfix/follow-buffer-directory

Add config option to follow buffer's directory
This commit is contained in:
Kiyan Yazdani 2020-05-18 23:52:24 +02:00 committed by GitHub
commit ab258d96f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 6 deletions

View File

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

View File

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