Skip to content

Commit 26e4066

Browse files
committed
doc: revert sort_by to simple
1 parent fda6d4c commit 26e4066

File tree

1 file changed

+1
-66
lines changed

1 file changed

+1
-66
lines changed

doc/nvim-tree-lua.txt

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -429,17 +429,6 @@ Can be one of `name`, `case_sensitive`, `modification_time`, `extension` or a
429429
function.
430430
Type: `string` | `function(nodes)`, Default: `"name"`
431431

432-
* Note that function(table) return Type `Table{ absolute_path }`
433-
434-
For example, to use pre-defined sorting method is done like this:
435-
>
436-
sort_by = "case_sensitive"
437-
438-
For example, to use simple user-defined sort_by function is done like this:
439-
440-
>
441-
sort_by = function(tbl)
442-
443432
Function is passed a table of nodes, each node containing:
444433
- `absolute_path`: `string`
445434
- `executable`: `boolean`
@@ -461,61 +450,7 @@ For example, to use simple user-defined sort_by function is done like this:
461450
end
462451
return order
463452
end
464-
465-
return user_oder
466-
end
467-
468-
Furthermore, You can try more complex example for sort_by function is done like this:
469-
470-
>
471-
sort_by = function(tbl)
472-
table.sort(tbl, function(a, b)
473-
if not (a and b) then
474-
return true
475-
end
476-
if a.type == "directory" and b.type ~= "directory" then
477-
return true
478-
elseif a.type ~= "directory" and b.type == "directory" then
479-
return false
480-
end
481-
482-
if a.type == "link" and b.type ~= "link" then
483-
return true
484-
elseif a.type ~= "link" and b.type == "link" then
485-
return false
486-
end
487-
488-
return a.name:lower() <= b.name:lower()
489-
-- return a.name <= b.name
490-
end) -- NOTE: organize directory, link, file in name order
491-
492-
-- sort by name, is directory?
493-
local i = 1
494-
while i <= #tbl do
495-
if tbl[i] and tbl[i].type == "directory" then
496-
local j = i + 1
497-
while j <= #tbl do
498-
if tbl[j] and tbl[j].type ~= "directory" and tbl[i].name:lower() == tbl[j].name:lower():match "(.+)%..+$" then
499-
local change_target = tbl[j]
500-
table.remove(tbl, j)
501-
table.insert(tbl, i, change_target)
502-
break
503-
end
504-
j = j + 1
505-
end
506-
end
507-
i = i + 1
508-
end
509-
510-
local user_order = {}
511-
for j = 1, #tbl do
512-
if tbl[j] then
513-
table.insert(user_order, tbl[j].absolute_path)
514-
end
515-
end
516-
return user_order
517-
end
518-
453+
<
519454
*nvim-tree.hijack_unnamed_buffer_when_opening*
520455
Opens in place of the unnamed buffer if it's empty.
521456
Type: `boolean`, Default: `false`

0 commit comments

Comments
 (0)