This commit is contained in:
committed by
GitHub
parent
33c3bc562b
commit
8f48426c88
@@ -2142,27 +2142,29 @@ Icon: >
|
|||||||
NvimTreeOpenedFolderIcon NvimTreeFolderIcon
|
NvimTreeOpenedFolderIcon NvimTreeFolderIcon
|
||||||
NvimTreeClosedFolderIcon NvimTreeFolderIcon
|
NvimTreeClosedFolderIcon NvimTreeFolderIcon
|
||||||
NvimTreeBookmark
|
NvimTreeBookmark
|
||||||
|
NvimTreeFolderArrowClosed NvimTreeIndentMarker
|
||||||
|
NvimTreeFolderArrowOpen NvimTreeIndentMarker
|
||||||
<
|
<
|
||||||
Indent: >
|
Indent: >
|
||||||
NvimTreeIndentMarker
|
NvimTreeIndentMarker
|
||||||
<
|
<
|
||||||
Standard: >
|
Standard: >
|
||||||
NvimTreeNormal Normal
|
NvimTreeNormal Normal
|
||||||
NvimTreeNormalFloat NormalFloat
|
NvimTreeNormalFloat NormalFloat
|
||||||
NvimTreeNormalNC NormalFloat
|
NvimTreeNormalNC NormalFloat
|
||||||
|
|
||||||
NvimTreeLineNr LineNr
|
NvimTreeLineNr LineNr
|
||||||
NvimTreeWinSeparator WinSeparator
|
NvimTreeWinSeparator WinSeparator
|
||||||
NvimTreeEndOfBuffer EndOfBuffer
|
NvimTreeEndOfBuffer EndOfBuffer
|
||||||
NvimTreePopup Normal
|
NvimTreePopup Normal
|
||||||
NvimTreeSignColumn NvimTreeNormal
|
NvimTreeSignColumn NvimTreeNormal
|
||||||
|
|
||||||
NvimTreeCursorColumn CursorColumn
|
NvimTreeCursorColumn CursorColumn
|
||||||
NvimTreeCursorLine CursorLine
|
NvimTreeCursorLine CursorLine
|
||||||
NvimTreeCursorLineNr CursorLineNr
|
NvimTreeCursorLineNr CursorLineNr
|
||||||
|
|
||||||
NvimTreeStatusLine StatusLine
|
NvimTreeStatusLine StatusLine
|
||||||
NvimTreeStatusLineNC StatusLineNC
|
NvimTreeStatusLineNC StatusLineNC
|
||||||
<
|
<
|
||||||
Picker: >
|
Picker: >
|
||||||
NvimTreeWindowPicker
|
NvimTreeWindowPicker
|
||||||
|
|||||||
@@ -290,14 +290,15 @@ function Builder:_get_highlight_override(node, unloaded_bufnr)
|
|||||||
return icon_hl, name_hl
|
return icon_hl, name_hl
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param padding HighlightedString
|
---@param indent_markers HighlightedString[]
|
||||||
|
---@param arrows HighlightedString[]|nil
|
||||||
---@param icon HighlightedString
|
---@param icon HighlightedString
|
||||||
---@param name HighlightedString
|
---@param name HighlightedString
|
||||||
---@param git_icons HighlightedString[]|nil
|
---@param git_icons HighlightedString[]|nil
|
||||||
---@param diagnostics_icon HighlightedString|nil
|
---@param diagnostics_icon HighlightedString|nil
|
||||||
---@param modified_icon HighlightedString|nil
|
---@param modified_icon HighlightedString|nil
|
||||||
---@return HighlightedString[]
|
---@return HighlightedString[]
|
||||||
function Builder:_format_line(padding, icon, name, git_icons, diagnostics_icon, modified_icon)
|
function Builder:_format_line(indent_markers, arrows, icon, name, git_icons, diagnostics_icon, modified_icon)
|
||||||
local added_len = 0
|
local added_len = 0
|
||||||
local function add_to_end(t1, t2)
|
local function add_to_end(t1, t2)
|
||||||
for _, v in ipairs(t2) do
|
for _, v in ipairs(t2) do
|
||||||
@@ -315,7 +316,7 @@ function Builder:_format_line(padding, icon, name, git_icons, diagnostics_icon,
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local line = { padding }
|
local line = { indent_markers, arrows }
|
||||||
add_to_end(line, { icon })
|
add_to_end(line, { icon })
|
||||||
if git_icons and self.git_placement == "before" then
|
if git_icons and self.git_placement == "before" then
|
||||||
add_to_end(line, git_icons)
|
add_to_end(line, git_icons)
|
||||||
@@ -344,7 +345,8 @@ end
|
|||||||
|
|
||||||
function Builder:_build_line(node, idx, num_children, unloaded_bufnr)
|
function Builder:_build_line(node, idx, num_children, unloaded_bufnr)
|
||||||
-- various components
|
-- various components
|
||||||
local padding = pad.get_padding(self.depth, idx, num_children, node, self.markers)
|
local indent_markers = pad.get_indent_markers(self.depth, idx, num_children, node, self.markers)
|
||||||
|
local arrows = pad.get_arrows(node)
|
||||||
local git_icons = self:_get_git_icons(node)
|
local git_icons = self:_get_git_icons(node)
|
||||||
local modified_icon = self:_get_modified_icon(node)
|
local modified_icon = self:_get_modified_icon(node)
|
||||||
local diagnostics_icon = self:_get_diagnostics_icon(node)
|
local diagnostics_icon = self:_get_diagnostics_icon(node)
|
||||||
@@ -370,7 +372,7 @@ function Builder:_build_line(node, idx, num_children, unloaded_bufnr)
|
|||||||
name.hl = name_hl
|
name.hl = name_hl
|
||||||
end
|
end
|
||||||
|
|
||||||
local line = self:_format_line(padding, icon, name, git_icons, diagnostics_icon, modified_icon)
|
local line = self:_format_line(indent_markers, arrows, icon, name, git_icons, diagnostics_icon, modified_icon)
|
||||||
self:_insert_line(self:_unwrap_highlighted_strings(line))
|
self:_insert_line(self:_unwrap_highlighted_strings(line))
|
||||||
|
|
||||||
self.index = self.index + 1
|
self.index = self.index + 1
|
||||||
|
|||||||
@@ -58,24 +58,14 @@ local function get_padding_indent_markers(depth, idx, nodes_number, markers, wit
|
|||||||
return padding
|
return padding
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_padding_arrows(node, indent)
|
|
||||||
if node.nodes then
|
|
||||||
return M.config.icons.glyphs.folder[node.open and "arrow_open" or "arrow_closed"] .. " "
|
|
||||||
elseif indent then
|
|
||||||
return " "
|
|
||||||
else
|
|
||||||
return ""
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
---@param depth integer
|
---@param depth integer
|
||||||
---@param idx integer
|
---@param idx integer
|
||||||
---@param nodes_number integer
|
---@param nodes_number integer
|
||||||
---@param node table
|
---@param node table
|
||||||
---@param markers table
|
---@param markers table
|
||||||
---@return HighlightedString
|
---@return HighlightedString[]
|
||||||
function M.get_padding(depth, idx, nodes_number, node, markers)
|
function M.get_indent_markers(depth, idx, nodes_number, node, markers)
|
||||||
local padding = ""
|
local str = ""
|
||||||
|
|
||||||
local show_arrows = M.config.icons.show.folder_arrow
|
local show_arrows = M.config.icons.show.folder_arrow
|
||||||
local show_markers = M.config.indent_markers.enable
|
local show_markers = M.config.indent_markers.enable
|
||||||
@@ -83,16 +73,38 @@ function M.get_padding(depth, idx, nodes_number, node, markers)
|
|||||||
local indent_width = M.config.indent_width
|
local indent_width = M.config.indent_width
|
||||||
|
|
||||||
if show_markers then
|
if show_markers then
|
||||||
padding = padding .. get_padding_indent_markers(depth, idx, nodes_number, markers, show_arrows, inline_arrows, node)
|
str = str .. get_padding_indent_markers(depth, idx, nodes_number, markers, show_arrows, inline_arrows, node)
|
||||||
else
|
else
|
||||||
padding = padding .. string.rep(" ", depth * indent_width)
|
str = str .. string.rep(" ", depth * indent_width)
|
||||||
end
|
end
|
||||||
|
|
||||||
if show_arrows then
|
return { str = str, hl = "NvimTreeIndentMarker" }
|
||||||
padding = padding .. get_padding_arrows(node, not show_markers)
|
end
|
||||||
|
|
||||||
|
---@param node table
|
||||||
|
---@return HighlightedString[]|nil
|
||||||
|
function M.get_arrows(node)
|
||||||
|
if not M.config.icons.show.folder_arrow then
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
return { str = padding, hl = "NvimTreeIndentMarker" }
|
local str
|
||||||
|
local hl = "NvimTreeFolderArrowClosed"
|
||||||
|
|
||||||
|
if node.nodes then
|
||||||
|
if node.open then
|
||||||
|
str = M.config.icons.glyphs.folder["arrow_open"] .. " "
|
||||||
|
hl = "NvimTreeFolderArrowOpen"
|
||||||
|
else
|
||||||
|
str = M.config.icons.glyphs.folder["arrow_closed"] .. " "
|
||||||
|
end
|
||||||
|
elseif M.config.indent_markers.enable then
|
||||||
|
str = ""
|
||||||
|
else
|
||||||
|
str = " "
|
||||||
|
end
|
||||||
|
|
||||||
|
return { str = str, hl = hl }
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.setup(opts)
|
function M.setup(opts)
|
||||||
|
|||||||
Reference in New Issue
Block a user