Skip to content

refactor(#2828): multi instance nvim-tree.explorer.filters #2841

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 5 commits into from
Jul 27, 2024

Conversation

raaymax
Copy link
Collaborator

@raaymax raaymax commented Jul 17, 2024

fixes #2828

@raaymax raaymax requested a review from alex-courtis July 17, 2024 23:18
@alex-courtis
Copy link
Member

Testing:

map an enable for testing

  vim.keymap.set('n', 'Z',     api.tree.toggle_enable_filters,        opts('Toggle All Filters'))

live filter OK

  • set
  • change
  • clear
  • combine with other filters

defaults, toggle each simple filter and enabled OK

  vim.keymap.set('n', 'Z',     api.tree.toggle_enable_filters,        opts('Toggle All Filters'))

  filters = {
    enable = true,
    git_ignored = true,
    dotfiles = false,
    git_clean = false,
    no_buffer = false,
    no_bookmark = false,
    custom = {},
    exclude = {},
  },

exclude OK

exclude = { 'CREDITS' },

custom OK

custom = { 'MAINTAINERS' },

custom function NO

    custom = function(absolute_path)
      print(vim.inspect(absolute_path))
      return absolute_path:match('.*config.*')
    end,

it looks like we're passing the node rather than the path

......
  },
  ignore_list = {},
  <metatable> = <8>{
    __index = <table 8>,
    new = <function 18>,
    prepare = <function 19>,
    should_filter = <function 20>
  }
}
E5108: Error executing lua: /tmp/nd/nd.lua:260: attempt to call method 'match' (a nil value)
stack traceback:
        /tmp/nd/nd.lua:260: in function 'custom_function'
        ...ilters-multi-instance/lua/nvim-tree/explorer/filters.lua:147: in function 'custom'
        ...ilters-multi-instance/lua/nvim-tree/explorer/filters.lua:211: in function 'should_filter'
        ...ilters-multi-instance/lua/nvim-tree/explorer/explore.lua:34: in function 'populate_children'
        ...ilters-multi-instance/lua/nvim-tree/explorer/explore.lua:70: in function 'explore'
        ...t/filters-multi-instance/lua/nvim-tree/explorer/init.lua:52: in function '_load'
        ...t/filters-multi-instance/lua/nvim-tree/explorer/init.lua:43: in function 'new'
        ...cker/start/filters-multi-instance/lua/nvim-tree/core.lua:20: in function 'init'
        ...acker/start/filters-multi-instance/lua/nvim-tree/lib.lua:261: in function 'open'
        ...lters-multi-instance/lua/nvim-tree/actions/tree/open.lua:32: in function 'open'

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 - making great progress and setting the patterns.

Small change and we're good to merge.

@raaymax raaymax requested a review from alex-courtis July 23, 2024 12:51
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.

Love your work!

@alex-courtis alex-courtis merged commit 908478a into master Jul 27, 2024
5 checks passed
@alex-courtis alex-courtis deleted the filters-multi-instance branch July 27, 2024 03:29
@raaymax
Copy link
Collaborator Author

raaymax commented Jul 27, 2024

🎉

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.

Multi Instance: Refactor: nvim-tree.explorer.filters
2 participants