1+ local config = require (" nvim-tree.config" )
12local DirectoryNode = require (" nvim-tree.node.directory" )
23
34local M = {}
@@ -27,21 +28,21 @@ local function get_padding_indent_markers(depth, idx, nodes_number, markers, wit
2728
2829 if depth > 0 then
2930 local has_folder_sibling = check_siblings_for_folder (node , with_arrows )
30- local indent = string.rep (" " , M . config .indent_width - 1 )
31+ local indent = string.rep (" " , config . g . renderer .indent_width - 1 )
3132 markers [depth ] = idx ~= nodes_number
3233 for i = 1 , depth - early_stop do
3334 local glyph
3435 if idx == nodes_number and i == depth then
35- local bottom_width = M . config .indent_width - 2 + (with_arrows and not inline_arrows and has_folder_sibling and 2 or 0 )
36- glyph = M . config .indent_markers .icons .corner
37- .. string.rep (M . config .indent_markers .icons .bottom , bottom_width )
38- .. (M . config .indent_width > 1 and " " or " " )
36+ local bottom_width = config . g . renderer .indent_width - 2 + (with_arrows and not inline_arrows and has_folder_sibling and 2 or 0 )
37+ glyph = config . g . renderer .indent_markers .icons .corner
38+ .. string.rep (config . g . renderer .indent_markers .icons .bottom , bottom_width )
39+ .. (config . g . renderer .indent_width > 1 and " " or " " )
3940 elseif markers [i ] and i == depth then
40- glyph = M . config .indent_markers .icons .item .. indent
41+ glyph = config . g . renderer .indent_markers .icons .item .. indent
4142 elseif markers [i ] then
42- glyph = M . config .indent_markers .icons .edge .. indent
43+ glyph = config . g . renderer .indent_markers .icons .edge .. indent
4344 else
44- glyph = M . config .indent_markers .icons .none .. indent
45+ glyph = config . g . renderer .indent_markers .icons .none .. indent
4546 end
4647
4748 if not with_arrows or (inline_arrows and (depth ~= i or not node .nodes )) then
6869function M .get_indent_markers (depth , idx , nodes_number , node , markers , early_stop )
6970 local str = " "
7071
71- local show_arrows = M . config .icons .show .folder_arrow
72- local show_markers = M . config .indent_markers .enable
73- local inline_arrows = M . config .indent_markers .inline_arrows
74- local indent_width = M . config .indent_width
72+ local show_arrows = config . g . renderer .icons .show .folder_arrow
73+ local show_markers = config . g . renderer .indent_markers .enable
74+ local inline_arrows = config . g . renderer .indent_markers .inline_arrows
75+ local indent_width = config . g . renderer .indent_width
7576
7677 if show_markers then
7778 str = str .. get_padding_indent_markers (depth , idx , nodes_number , markers , show_arrows , inline_arrows , node , early_stop or 0 )
8586--- @param node Node
8687--- @return nvim_tree.api.highlighted_string[] ?
8788function M .get_arrows (node )
88- if not M . config .icons .show .folder_arrow then
89+ if not config . g . renderer .icons .show .folder_arrow then
8990 return
9091 end
9192
@@ -95,38 +96,18 @@ function M.get_arrows(node)
9596 local dir = node :as (DirectoryNode )
9697 if dir then
9798 if dir .open then
98- str = M . config .icons .glyphs .folder [" arrow_open" ] .. M . config .icons .padding .folder_arrow
99+ str = config .g . renderer . icons .glyphs .folder [" arrow_open" ] .. config . g . renderer .icons .padding .folder_arrow
99100 hl = " NvimTreeFolderArrowOpen"
100101 else
101- str = M . config .icons .glyphs .folder [" arrow_closed" ] .. M . config .icons .padding .folder_arrow
102+ str = config .g . renderer . icons .glyphs .folder [" arrow_closed" ] .. config . g . renderer .icons .padding .folder_arrow
102103 end
103- elseif M . config .indent_markers .enable then
104+ elseif config . g . renderer .indent_markers .enable then
104105 str = " "
105106 else
106- str = " " .. string.rep (" " , # M . config .icons .padding .folder_arrow )
107+ str = " " .. string.rep (" " , # config . g . renderer .icons .padding .folder_arrow )
107108 end
108109
109110 return { str = str , hl = { hl } }
110111end
111112
112- function M .setup (opts )
113- M .config = opts .renderer
114-
115- if M .config .indent_width < 1 then
116- M .config .indent_width = 1
117- end
118-
119- local function check_marker (symbol )
120- if # symbol == 0 then
121- return " "
122- end
123- -- return the first character from the UTF-8 encoded string; we may use utf8.codes from Lua 5.3 when available
124- return symbol :match (" [%z\1 -\127\194 -\244 ][\128 -\191 ]*" )
125- end
126-
127- for k , v in pairs (M .config .indent_markers .icons ) do
128- M .config .indent_markers .icons [k ] = check_marker (v )
129- end
130- end
131-
132113return M
0 commit comments