Merge root folder and parent navigator into one.

This commit is contained in:
Kristijan Husak 2020-08-03 20:51:01 +02:00 committed by Kiyan Yazdani
parent 0d8b22c1e9
commit 859be0bb76
3 changed files with 6 additions and 12 deletions

View File

@ -146,7 +146,7 @@ Can be `0` or `1`. When `1`, will hide dotfiles, files or folders which start
with the `.` character. with the `.` character.
Default is 0 Default is 0
|g:lua_tree_root_folder_modifier| *g:lua_tree_hide_dotfiles* |g:lua_tree_root_folder_modifier| *g:lua_tree_root_folder_modifier*
In what format to show root folder. See `:help filename-modifiers` for In what format to show root folder. See `:help filename-modifiers` for
available options. available options.

View File

@ -58,7 +58,7 @@ function M.init(with_open, with_render)
end end
local function get_node_at_line(line) local function get_node_at_line(line)
local index = 3 local index = 2
local function iter(entries) local function iter(entries)
for _, node in ipairs(entries) do for _, node in ipairs(entries) do
if index == line then if index == line then
@ -135,9 +135,9 @@ end
function M.set_index_and_redraw(fname) function M.set_index_and_redraw(fname)
local i local i
if M.Tree.cwd == '/' then if M.Tree.cwd == '/' then
i = 1 i = 0
else else
i = 2 i = 1
end end
local reload = false local reload = false

View File

@ -164,16 +164,10 @@ local root_folder_modifier = vim.g.lua_tree_root_folder_modifier or ':~'
local function update_draw_data(tree, depth, markers) local function update_draw_data(tree, depth, markers)
if tree.cwd and tree.cwd ~= '/' then if tree.cwd and tree.cwd ~= '/' then
table.insert(lines, ".. (up a dir)") local root_name = vim.fn.fnamemodify(tree.cwd, root_folder_modifier):gsub('/$', '').."/.."
table.insert(hl, {'LuaTreeFolderName', index, 0, 13})
index = 1
end
if tree.cwd then
local root_name = vim.fn.fnamemodify(tree.cwd, root_folder_modifier)
table.insert(lines, root_name) table.insert(lines, root_name)
table.insert(hl, {'LuaTreeRootFolder', index, 0, string.len(root_name)}) table.insert(hl, {'LuaTreeRootFolder', index, 0, string.len(root_name)})
index = tree.cwd ~= '/' and 2 or 1 index = 1
end end
for idx, node in ipairs(tree.entries) do for idx, node in ipairs(tree.entries) do