Skip to content

Commit 2077cc3

Browse files
feat: case insensitive sorting (#429)
* check for sorting option in netrw * documentation * refactor: remove sort_ prefix --------- Co-authored-by: Steven Arcangeli <[email protected]>
1 parent c7c7ce5 commit 2077cc3

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ require("oil").setup({
216216
-- Sort file names in a more intuitive order for humans. Is less performant,
217217
-- so you may want to set to false if you work with large directories.
218218
natural_order = true,
219+
-- Sort file and directory names case insensitive
220+
case_insensitive = false,
219221
sort = {
220222
-- sort order can be "asc" or "desc"
221223
-- see :help oil-columns to see which columns are sortable

doc/oil.txt

+2
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ CONFIG *oil-confi
106106
-- Sort file names in a more intuitive order for humans. Is less performant,
107107
-- so you may want to set to false if you work with large directories.
108108
natural_order = true,
109+
-- Sort file and directory names case insensitive
110+
case_insensitive = false,
109111
sort = {
110112
-- sort order can be "asc" or "desc"
111113
-- see :help oil-columns to see which columns are sortable

lua/oil/columns.lua

+9-3
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,17 @@ M.register("name", {
300300
end,
301301

302302
get_sort_value = function(entry)
303+
local sort_value = entry[FIELD_NAME]
304+
303305
if config.view_options.natural_order then
304-
return entry[FIELD_NAME]:gsub("%d+", pad_number)
305-
else
306-
return entry[FIELD_NAME]
306+
sort_value = sort_value:gsub("%d+", pad_number)
307307
end
308+
309+
if config.view_options.case_insensitive then
310+
sort_value = sort_value:lower()
311+
end
312+
313+
return sort_value
308314
end,
309315
})
310316

lua/oil/config.lua

+2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ local default_config = {
9191
-- Sort file names in a more intuitive order for humans. Is less performant,
9292
-- so you may want to set to false if you work with large directories.
9393
natural_order = true,
94+
-- Sort file and directory names case insensitive
95+
case_insensitive = false,
9496
sort = {
9597
-- sort order can be "asc" or "desc"
9698
-- see :help oil-columns to see which columns are sortable

0 commit comments

Comments
 (0)