Skip to content

Add config option to follow buffer's directory #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions lua/tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions plugin/tree.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down