feat: add trailing slash on folder names
enable the feature through `vim.g.nvim_tree_add_trailing`
This commit is contained in:
parent
4c46d2b192
commit
f7ad4ce5f4
@ -33,6 +33,7 @@ let g:nvim_tree_tab_open = 1 "0 by default, will open the tree when entering a n
|
||||
let g:nvim_tree_width_allow_resize = 1 "0 by default, will not resize the tree when opening a file
|
||||
let g:nvim_tree_disable_netrw = 0 "1 by default, disables netrw
|
||||
let g:nvim_tree_hijack_netrw = 0 "1 by default, prevents netrw from automatically opening when opening directories (but lets you keep its other utilities)
|
||||
let g:nvim_tree_add_trailing = 1 "0 by default, append a trailing slash to folder names
|
||||
let g:nvim_tree_show_icons = {
|
||||
\ 'git': 1,
|
||||
\ 'folders': 0,
|
||||
|
||||
@ -198,6 +198,10 @@ Can be 0 or 1. When 1, completely disable netrw and all related
|
||||
functionnalities.
|
||||
1 by default.
|
||||
|
||||
|g:nvim_tree_add_trailing| *g:nvim_tree_add_trailing*
|
||||
|
||||
Can be 0 or 1. When 1, appends a trailing slash to folder names.
|
||||
0 by default.
|
||||
|
||||
==============================================================================
|
||||
INFORMATIONS *nvim-tree-info*
|
||||
|
||||
@ -131,9 +131,9 @@ function M.on_enter()
|
||||
if is_dir then
|
||||
api.nvim_command('cd '..bufname)
|
||||
end
|
||||
local should_open = vim.g.nvim_tree_auto_open == 1 and
|
||||
((is_dir and (hijack_netrw == 1 or disable_netrw == 1)) or bufname == '') and
|
||||
not vim.tbl_contains(ft_ignore, buftype)
|
||||
local should_open = vim.g.nvim_tree_auto_open == 1
|
||||
and ((is_dir and (hijack_netrw == 1 or disable_netrw == 1)) or bufname == '')
|
||||
and not vim.tbl_contains(ft_ignore, buftype)
|
||||
lib.init(should_open, should_open)
|
||||
end
|
||||
|
||||
|
||||
@ -11,8 +11,12 @@ local namespace_id = api.nvim_create_namespace('NvimTreeHighlights')
|
||||
local icon_state = config.get_icon_state()
|
||||
|
||||
local get_folder_icon = function() return "" end
|
||||
local function get_trailing_length()
|
||||
return vim.g.nvim_tree_add_trailing and 1 or 0
|
||||
end
|
||||
|
||||
local set_folder_hl = function(line, depth, git_icon_len, _, hl_group)
|
||||
table.insert(hl, {hl_group, line, depth+git_icon_len, -1})
|
||||
table.insert(hl, {hl_group, line, depth+git_icon_len+get_trailing_length(), -1})
|
||||
end
|
||||
|
||||
if icon_state.show_folder_icon then
|
||||
@ -36,7 +40,7 @@ if icon_state.show_folder_icon then
|
||||
return n.." "
|
||||
end
|
||||
set_folder_hl = function(line, depth, icon_len, name_len, hl_group)
|
||||
table.insert(hl, {hl_group, line, depth+icon_len, depth+icon_len+name_len})
|
||||
table.insert(hl, {hl_group, line, depth+icon_len, depth+icon_len+name_len+get_trailing_length()})
|
||||
table.insert(hl, {'NvimTreeFolderIcon', line, depth, depth+icon_len})
|
||||
end
|
||||
end
|
||||
@ -253,10 +257,10 @@ local function update_draw_data(tree, depth, markers)
|
||||
end
|
||||
index = index + 1
|
||||
if node.open then
|
||||
table.insert(lines, padding..icon..git_icon..node.name)
|
||||
table.insert(lines, padding..icon..git_icon..node.name..(vim.g.nvim_tree_add_trailing == 1 and '/' or ''))
|
||||
update_draw_data(node, depth + 2, markers)
|
||||
else
|
||||
table.insert(lines, padding..icon..git_icon..node.name)
|
||||
table.insert(lines, padding..icon..git_icon..node.name..(vim.g.nvim_tree_add_trailing == 1 and '/' or ''))
|
||||
end
|
||||
elseif node.link_to then
|
||||
local icon = get_symlink_icon()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user