Add root folder name.

This commit is contained in:
Kristijan Husak
2020-08-03 18:46:10 +02:00
committed by Kiyan Yazdani
parent 2a3c9cfd12
commit caf238d908
5 changed files with 23 additions and 5 deletions

View File

@@ -160,13 +160,22 @@ local special = {
["readme.md"] = true,
}
local root_folder_modifier = vim.g.lua_tree_root_folder_modifier or ':~'
local function update_draw_data(tree, depth, markers)
if tree.cwd and tree.cwd ~= '/' then
table.insert(lines, "..")
table.insert(hl, {'LuaTreeFolderName', index, 0, 2})
table.insert(lines, ".. (up a dir)")
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(hl, {'LuaTreeRootFolder', index, 0, string.len(root_name)})
index = tree.cwd ~= '/' and 2 or 1
end
for idx, node in ipairs(tree.entries) do
local padding = get_padding(depth, idx, tree, node, markers)
local offset = string.len(padding)