Add config option to follow buffer directory
This commit is contained in:
parent
5fcbc21edb
commit
9201d123fd
16
lua/tree.lua
16
lua/tree.lua
@ -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
|
||||||
|
|
||||||
|
|||||||
@ -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
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user