Skip to content

feat: add sort_by "filetype" #2302

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 9, 2023

Conversation

moniquelive
Copy link
Collaborator

@moniquelive moniquelive commented Jul 1, 2023

Fixes #2288 by proposing a new kind of sorting: by vim's filetype.

Copy link
Member

@alex-courtis alex-courtis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contibution!

This somewhat works however we're at the mercy of filesystem/discovery ordering.

rm * ; touch 20.yaml 30.toml 40.cpp 41.cpp 10.zig 35.nothing 25.nothing

     20.yaml
     10.zig
     25.nothing
     30.toml
     35.nothing
     40.cpp
     41.cpp

rm * ; touch 20.yaml 30.toml 40.cpp 41.cpp 10.zig 35.nothing 25.nothing 21.nothing

     40.cpp
     41.cpp
     30.toml
     20.yaml
     10.zig
     21.nothing
     25.nothing
     35.nothing

Please:

  • add a fallback for the whatever cases - I think name is best.

I'd be grateful if you could add the same fallback to extension however that can be a subsequent PR.

@alex-courtis
Copy link
Member

sorters.lua merge sort is complex, added for performance reasons #334

Being mindful of Chesterton's fence it might be time to simplify to drop back to the basic quick sort table.sort

Copy link
Member

@alex-courtis alex-courtis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works nicely:

rm -rf * ; touch 20.yaml 30.toml 40.cpp 41.cpp 10.zig 35.nothing 25.nothing ; mkdir -p 15/a ; touch 15/a/10.toml 15/a/20.nothing 15/a/10.yaml

  ~/2302/..                   │
    15/a                    │~
       10.toml               │~
       10.yaml               │~
       20.nothing            │~
     40.cpp                  │~
     41.cpp                  │~
     30.toml                 │~
     20.yaml                 │~
     10.zig                  │~
     25.nothing              │~
     35.nothing              │~

@alex-courtis alex-courtis changed the title feat: adds new type of sorting based on vim's filetype detection feat: add sort_by "filetype" Jul 9, 2023
@alex-courtis alex-courtis merged commit 3d2fd90 into nvim-tree:master Jul 9, 2023
@moniquelive moniquelive deleted the add-filetype-sorting branch July 9, 2023 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sorting with name.<EXT PREFIX>.ext is based on <EXT PREFIX> instead of .ext
2 participants