Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Feature/case insensitive sorting #429

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ require("oil").setup({
-- Sort file names in a more intuitive order for humans. Is less performant,
-- so you may want to set to false if you work with large directories.
natural_order = true,
-- Sort file and directory names case insensitive
case_insensitive = false,
sort = {
-- sort order can be "asc" or "desc"
-- see :help oil-columns to see which columns are sortable
Expand Down
2 changes: 2 additions & 0 deletions doc/oil.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ CONFIG *oil-confi
-- Sort file names in a more intuitive order for humans. Is less performant,
-- so you may want to set to false if you work with large directories.
natural_order = true,
-- Sort file and directory names case insensitive
case_insensitive = false,
sort = {
-- sort order can be "asc" or "desc"
-- see :help oil-columns to see which columns are sortable
Expand Down
12 changes: 9 additions & 3 deletions lua/oil/columns.lua
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,17 @@ M.register("name", {
end,

get_sort_value = function(entry)
local sort_value = entry[FIELD_NAME]

if config.view_options.natural_order then
return entry[FIELD_NAME]:gsub("%d+", pad_number)
else
return entry[FIELD_NAME]
sort_value = sort_value:gsub("%d+", pad_number)
end

if config.view_options.case_insensitive then
sort_value = sort_value:lower()
end

return sort_value
end,
})

Expand Down
2 changes: 2 additions & 0 deletions lua/oil/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ local default_config = {
-- Sort file names in a more intuitive order for humans. Is less performant,
-- so you may want to set to false if you work with large directories.
natural_order = true,
-- Sort file and directory names case insensitive
case_insensitive = false,
sort = {
-- sort order can be "asc" or "desc"
-- see :help oil-columns to see which columns are sortable
Expand Down