feat: add option for folder arrows to be inline with indent markers (#1468)

This commit is contained in:
Austin Harris 2022-07-28 04:49:23 -05:00 committed by GitHub
parent ac90664001
commit 7fcb48c852
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 4 deletions

View File

@ -201,6 +201,7 @@ Subsequent calls to setup will replace the previous configuration.
root_folder_modifier = ":~",
indent_markers = {
enable = false,
inline_arrows = true,
icons = {
corner = "└",
edge = "│",
@ -670,6 +671,11 @@ UI rendering setup
Display indent markers when folders are open
Type: `boolean`, Default: `false`
*nvim-tree.renderer.indent_markers.inline_arrows*
Display folder arrows in the same column as indent marker
when using |renderer.icons.show.folder_arrow|
Type: `boolean`, Default: `true`
*nvim-tree.renderer.indent_markers.icons*
Icons shown before the file/directory.
Type: `table`, Default: `{ corner = "└", edge = "│", item = "│", none = " ", }`

View File

@ -464,6 +464,7 @@ local DEFAULT_OPTS = { -- BEGIN_DEFAULT_OPTS
root_folder_modifier = ":~",
indent_markers = {
enable = false,
inline_arrows = true,
icons = {
corner = "",
edge = "",

View File

@ -19,9 +19,9 @@ local function check_siblings_for_folder(node, with_arrows)
return false
end
local function get_padding_indent_markers(depth, idx, nodes_number, markers, with_arrows, node)
local function get_padding_indent_markers(depth, idx, nodes_number, markers, with_arrows, inline_arrows, node)
local base_padding = with_arrows and (not node.nodes or depth > 0) and " " or ""
local padding = base_padding
local padding = (inline_arrows or depth == 0) and base_padding or ""
if depth > 0 then
local has_folder_sibling = check_siblings_for_folder(node, with_arrows)
@ -39,8 +39,10 @@ local function get_padding_indent_markers(depth, idx, nodes_number, markers, wit
glyph = M.config.indent_markers.icons.none
end
if not with_arrows or i == 1 then
if not with_arrows or (inline_arrows and (rdepth ~= i or not node.nodes)) then
padding = padding .. glyph .. " "
elseif inline_arrows then
padding = padding
elseif idx == nodes_number and i == rdepth and has_folder_sibling then
padding = padding .. base_padding .. glyph .. "── "
elseif rdepth == i and not node.nodes and has_folder_sibling then
@ -68,9 +70,10 @@ function M.get_padding(depth, idx, nodes_number, node, markers)
local show_arrows = M.config.icons.show.folder_arrow
local show_markers = M.config.indent_markers.enable
local inline_arrows = M.config.indent_markers.inline_arrows
if show_markers then
padding = padding .. get_padding_indent_markers(depth, idx, nodes_number, markers, show_arrows, node)
padding = padding .. get_padding_indent_markers(depth, idx, nodes_number, markers, show_arrows, inline_arrows, node)
else
padding = padding .. string.rep(" ", depth)
end