Skip to content

Commit 3ca7fd0

Browse files
committed
fix small bug with indent markers, add notice to README for netrw and gx
1 parent 545ecbc commit 3ca7fd0

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ highlight LuaTreeFolderIcon guibg=blue
107107

108108
This plugin is very fast because it uses the `libuv` `scandir` and `scandir_next` functions instead of spawning an `ls` process which can get slow on large files when combining with `stat` to get file informations.
109109

110+
The Netrw vim plugin is disabled, hence features like `gx` don't work accross your windows/buffers. You could use a plugin like [this one](https://github.com/stsewd/gx-extended.vim) if you wish to use that feature.
111+
110112
## Features
111113
- Open file in current buffer or in split with FzF like bindings (`<CR>`, `<C-v>`, `<C-x>`, `<C-t>`)
112114
- File icons with nvim-web-devicons

lua/lib/renderer.lua

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,16 @@ local get_padding = function(depth)
9292
end
9393

9494
if vim.g.lua_tree_indent_markers == 1 then
95-
get_padding = function(depth, idx, tree, node)
95+
get_padding = function(depth, idx, tree, node, last_node)
9696
local padding = ""
9797
if depth ~= 0 then
9898
for i=1,depth/2 do
9999
if idx == #tree.entries and i == depth/2 then
100100
padding = padding..''
101-
else
101+
elseif not last_node or i < (depth/2) - 1 then
102102
padding = padding..''
103+
else
104+
padding = padding..' '
103105
end
104106
end
105107
end
@@ -121,15 +123,15 @@ local special = {
121123
["readme.md"] = true,
122124
}
123125

124-
local function update_draw_data(tree, depth)
126+
local function update_draw_data(tree, depth, last_node)
125127
if tree.cwd and tree.cwd ~= '/' then
126128
table.insert(lines, "..")
127129
table.insert(hl, {'LuaTreeFolderName', index, 0, 2})
128130
index = 1
129131
end
130132

131133
for idx, node in ipairs(tree.entries) do
132-
local padding = get_padding(depth, idx, tree, node)
134+
local padding = get_padding(depth, idx, tree, node, last_node)
133135
local offset = string.len(padding)
134136
if depth > 0 then
135137
table.insert(hl, { 'LuaTreeIndentMarker', index, 0, offset })
@@ -141,7 +143,7 @@ local function update_draw_data(tree, depth)
141143
index = index + 1
142144
if node.open then
143145
table.insert(lines, padding..icon..node.name.." "..git_icon)
144-
update_draw_data(node, depth + 2)
146+
update_draw_data(node, depth + 2, idx == #tree.entries)
145147
else
146148
table.insert(lines, padding..icon..node.name.." "..git_icon)
147149
end

0 commit comments

Comments
 (0)