Skip to content

refactor(#2829): multi instance nvim-tree.explorer.sorters #2835

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

Merged
merged 8 commits into from
Jul 27, 2024

Conversation

raaymax
Copy link
Collaborator

@raaymax raaymax commented Jul 13, 2024

Implementation for #2829

fixes #2829

@alex-courtis alex-courtis changed the title refactor: multi instance nvim-tree.explorer.sorters refactor(#2829): multi instance nvim-tree.explorer.sorters Jul 14, 2024
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.

This is just fantastic! Thank you for leading the charge here.

This one will be the pattern for other such tasks!

@raaymax
Copy link
Collaborator Author

raaymax commented Jul 14, 2024

Thank you, @alex-courtis I'm glad you liked it. I'm just really excited about this functionality and happy to help.

@raaymax raaymax requested a review from alex-courtis July 14, 2024 11:50
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.

Looking really good... except for the presets.

auto refresh OK

  sort = {
    sorter = "name",
    folders_first = true,
    files_first = false,
  },
  filesystem_watchers = {
    enable = true,
  },

manual refresh OK

  sort = {
    sorter = "name",
    folders_first = true,
    files_first = false,
  },
  filesystem_watchers = {
    enable = false,
  },

file/folder comb OK

  sort = {
    sorter = "name",
    folders_first = false,
    files_first = false,
  },
  filesystem_watchers = {
    enable = false,
  },
  sort = {
    sorter = "name",
    folders_first = false,
    files_first = true,
  },
  filesystem_watchers = {
    enable = false,
  },
  sort = {
    sorter = "name",
    folders_first = true,
    files_first = true,
  },
  filesystem_watchers = {
    enable = false,
  },

function OK

  sort = {
    sorter = function(nodes)
      table.sort(nodes, function(a, b)
        return #a.name < #b.name
      end)
    end,
    folders_first = true,
    files_first = false,
  },
  filesystem_watchers = {
    enable = true,
  },

extension NO, similar for other presets

  sort = {
    sorter = "extension",
    folders_first = true,
    files_first = false,
  },
  filesystem_watchers = {
    enable = true,
  },
E5108: Error executing lua: .../packer/start/raaymax/lua/nvim-tree/explorer/sorters.lua:46: attempt to index local 'cfg' (a nil value)
stack traceback:
        .../packer/start/raaymax/lua/nvim-tree/explorer/sorters.lua:46: in function 'folders_or_files_first'
        .../packer/start/raaymax/lua/nvim-tree/explorer/sorters.lua:198: in function 'comparator'
        .../packer/start/raaymax/lua/nvim-tree/explorer/sorters.lua:74: in function 'merge'
        .../packer/start/raaymax/lua/nvim-tree/explorer/sorters.lua:110: in function 'split_merge'
        .../packer/start/raaymax/lua/nvim-tree/explorer/sorters.lua:108: in function 'split_merge'
        .../packer/start/raaymax/lua/nvim-tree/explorer/sorters.lua:108: in function 'split_merge'
        .../packer/start/raaymax/lua/nvim-tree/explorer/sorters.lua:108: in function 'split_merge'
        .../packer/start/raaymax/lua/nvim-tree/explorer/sorters.lua:108: in function 'split_merge'
        .../packer/start/raaymax/lua/nvim-tree/explorer/sorters.lua:108: in function 'split_merge'
        .../packer/start/raaymax/lua/nvim-tree/explorer/sorters.lua:160: in function 'sort'
        .../packer/start/raaymax/lua/nvim-tree/explorer/explore.lua:83: in function 'explore'
        ...ack/packer/start/raaymax/lua/nvim-tree/explorer/init.lua:52: in function '_load'
        ...ack/packer/start/raaymax/lua/nvim-tree/explorer/init.lua:43: in function 'new'
        ...nd/site/pack/packer/start/raaymax/lua/nvim-tree/core.lua:20: in function 'init'
        .../nd/site/pack/packer/start/raaymax/lua/nvim-tree/lib.lua:261: in function 'open'
        ...packer/start/raaymax/lua/nvim-tree/actions/tree/open.lua:32: in function 'open'

@@ -36,6 +37,7 @@ function Explorer.new(path)
absolute_path = path,
nodes = {},
open = true,
sorters = Sorters:new(M.config),
Copy link
Member

Choose a reason for hiding this comment

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

That worked out rather nicely.

@alex-courtis
Copy link
Member

Apologies for the delayed review; I'm only able to work on nvim-tree on weekends (AEST).

@gegoune
Copy link
Collaborator

gegoune commented Jul 20, 2024

@alex-courtis accidental close?

@alex-courtis
Copy link
Member

alex-courtis commented Jul 21, 2024

@alex-courtis accidental close?

Oh crap, thank you.

No more <c-enter> in text boxes for me.

@alex-courtis alex-courtis reopened this Jul 21, 2024
@raaymax
Copy link
Collaborator Author

raaymax commented Jul 23, 2024

I fixed issue you mentioned.
No worries about the delays, they are inevitable.
My time is also really limited, currently, I can only allocate 1-2 hours per week to this project.

@raaymax raaymax requested a review from alex-courtis July 23, 2024 12:51
@alex-courtis alex-courtis force-pushed the sorters_instantiable branch from 88a50c0 to 0ad7258 Compare July 27, 2024 03:50
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.

Just fantastic...

All test + all presets tested OK.

@alex-courtis alex-courtis merged commit 82ba116 into nvim-tree:master Jul 27, 2024
5 checks passed
@raaymax raaymax deleted the sorters_instantiable branch July 27, 2024 10:28
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multi Instance: Refactor: nvim-tree.explorer.sorters
3 participants