Merge pull request #13 from Akin909/bugfix/follow-buffer-directory
Add config option to follow buffer's directory
This commit is contained in:
commit
ab258d96f6
16
lua/tree.lua
16
lua/tree.lua
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user