Skip to content

Commit

Permalink
feat: configurable indent level
Browse files Browse the repository at this point in the history
  • Loading branch information
sand4rt committed Sep 28, 2024
1 parent a77af2e commit 86a78c5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ use {
},
indent = {
indent_size = 2,
level = 2,
padding = 1, -- extra padding on left hand side
-- indent guides
with_markers = true,
Expand Down
1 change: 1 addition & 0 deletions doc/neo-tree.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,7 @@ for each source, or just do it once in the default_component_configs section:
indent_marker = "│",
last_indent_marker = "└",
indent_size = 2,
level = 2
},
},
})
Expand Down
7 changes: 4 additions & 3 deletions lua/neo-tree/sources/common/components.lua
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ M.indent = function(config, node, state)
local skip_marker = state.skip_marker_at_level
local indent_size = config.indent_size or 2
local padding = config.padding or 0
local start_level = config.level or 2
local level = node.level
local with_markers = config.with_markers
local with_expanders = config.with_expanders == nil and file_nesting.is_enabled()
Expand All @@ -403,7 +404,7 @@ M.indent = function(config, node, state)
end
end

if indent_size == 0 or level < 2 or not with_markers then
if indent_size == 0 or level < 0 or not with_markers then
local len = indent_size * level + padding
local expander = get_expander()
if level == 0 or not expander then
Expand All @@ -426,12 +427,12 @@ M.indent = function(config, node, state)
table.insert(indent, { text = string.rep(" ", padding) })
end

for i = 1, level do
for i = start_level - 1, level do
local char = ""
local spaces_count = indent_size
local highlight = nil

if i > 1 and not skip_marker[i] or i == level then
if i > start_level - 1 and not skip_marker[i] or i == level then
spaces_count = spaces_count - 1
char = indent_marker
highlight = marker_highlight
Expand Down

0 comments on commit 86a78c5

Please sign in to comment.