Add root folder name.
This commit is contained in:
committed by
Kiyan Yazdani
parent
2a3c9cfd12
commit
caf238d908
@@ -33,6 +33,7 @@ let g:lua_tree_follow = 1 "0 by default, this option allows the cursor to be upd
|
|||||||
let g:lua_tree_indent_markers = 1 "0 by default, this option shows indent markers when folders are open
|
let g:lua_tree_indent_markers = 1 "0 by default, this option shows indent markers when folders are open
|
||||||
let g:lua_tree_hide_dotfiles = 1 "0 by default, this option hides files and folders starting with a dot `.`
|
let g:lua_tree_hide_dotfiles = 1 "0 by default, this option hides files and folders starting with a dot `.`
|
||||||
let g:lua_tree_git_hl = 1 "0 by default, will enable file highlight for git attributes (can be used without the icons).
|
let g:lua_tree_git_hl = 1 "0 by default, will enable file highlight for git attributes (can be used without the icons).
|
||||||
|
let g:lua_tree_root_folder_modifier = ':~' "This is the default. See :help filename-modifiers for more options
|
||||||
let g:lua_tree_show_icons = {
|
let g:lua_tree_show_icons = {
|
||||||
\ 'git': 1,
|
\ 'git': 1,
|
||||||
\ 'folders': 0,
|
\ 'folders': 0,
|
||||||
|
|||||||
@@ -146,6 +146,12 @@ 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*
|
||||||
|
|
||||||
|
In what format to show root folder. See `:help filename-modifiers` for
|
||||||
|
available options.
|
||||||
|
Default is `:~`
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
INFORMATIONS *nvim-tree-info*
|
INFORMATIONS *nvim-tree-info*
|
||||||
|
|
||||||
@@ -241,6 +247,7 @@ applied.
|
|||||||
|
|
||||||
LuaTreeSymlink
|
LuaTreeSymlink
|
||||||
LuaTreeFolderName
|
LuaTreeFolderName
|
||||||
|
LuaTreeRootFolder
|
||||||
LuaTreeFolderIcon
|
LuaTreeFolderIcon
|
||||||
LuaTreeExecFile
|
LuaTreeExecFile
|
||||||
LuaTreeSpecialFile
|
LuaTreeSpecialFile
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ local function get_hl_groups()
|
|||||||
IndentMarker = { fg = '#8094b4' },
|
IndentMarker = { fg = '#8094b4' },
|
||||||
Symlink = { gui = 'bold', fg = colors.cyan },
|
Symlink = { gui = 'bold', fg = colors.cyan },
|
||||||
FolderIcon = { fg = '#8094b4' },
|
FolderIcon = { fg = '#8094b4' },
|
||||||
|
RootFolder = { fg = colors.purple },
|
||||||
|
|
||||||
ExecFile = { gui = 'bold', fg = colors.green },
|
ExecFile = { gui = 'bold', fg = colors.green },
|
||||||
SpecialFile = { gui = 'bold,underline', fg = colors.yellow },
|
SpecialFile = { gui = 'bold,underline', fg = colors.yellow },
|
||||||
|
|||||||
@@ -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 = 2
|
local index = 3
|
||||||
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 = 0
|
|
||||||
else
|
|
||||||
i = 1
|
i = 1
|
||||||
|
else
|
||||||
|
i = 2
|
||||||
end
|
end
|
||||||
local reload = false
|
local reload = false
|
||||||
|
|
||||||
|
|||||||
@@ -160,13 +160,22 @@ local special = {
|
|||||||
["readme.md"] = true,
|
["readme.md"] = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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, "..")
|
table.insert(lines, ".. (up a dir)")
|
||||||
table.insert(hl, {'LuaTreeFolderName', index, 0, 2})
|
table.insert(hl, {'LuaTreeFolderName', index, 0, 13})
|
||||||
index = 1
|
index = 1
|
||||||
end
|
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
|
for idx, node in ipairs(tree.entries) do
|
||||||
local padding = get_padding(depth, idx, tree, node, markers)
|
local padding = get_padding(depth, idx, tree, node, markers)
|
||||||
local offset = string.len(padding)
|
local offset = string.len(padding)
|
||||||
|
|||||||
Reference in New Issue
Block a user