nvim-neo-tree / neo-tree.nvim

Neovim plugin to manage the file system and other tree like structures.
MIT License
3.86k stars 224 forks source link

Support fuzzy file filtering ala fzf, where present nonconsecutive letters show up #851

Open dimroc opened 1 year ago

dimroc commented 1 year ago

https://github.com/nvim-neo-tree/neo-tree.nvim/blob/2b2f74828eeb02cf29d6b21aa32eedadadc94ca7/lua/neo-tree/sources/filesystem/lib/filter_external.lua#L197-L201

The current file filter looks for contiguous blocks of text at the beginning of the path. It would be great if we could get fzf file filtering ala command-T. Seems like the work was started above.

nhat-vo commented 1 year ago

Does the fuzzy_sorter satisfy your use case?

# = fuzzy_sorter:           Sort the tree recursively based on fzy algorithm,
                            showing top score files. Space separated keywords
                            are treated as `and` which will be useful to narrow
                            down as you type. The file list is taken from fd
                            and other programs mentioned in `fuzzy_finder`.
                            `fuzzy_sorter_directory` can be used to show list
                            of directories instead.

You can enable this like in the example here.

nhat-vo commented 1 year ago

Closing this as solved.

dimroc commented 1 year ago

Does the fuzzy_sorter satisfy your use case?


# = fuzzy_sorter:           Sort the tree recursively based on fzy algorithm,

                            showing top score files. Space separated keywords

                            are treated as `and` which will be useful to narrow

                            down as you type. The file list is taken from fd

                            and other programs mentioned in `fuzzy_finder`.

                            `fuzzy_sorter_directory` can be used to show list

                            of directories instead.

You can enable this like in the example here.

This doesn't achieve what I'm hoping for. While this has the word fuzzy, it doesn't allow arbitrary combination of letters without spaces to be a presence check for files like FZF does

dimroc commented 1 year ago

Example to knowledge share

cseickel commented 1 year ago

I get what you're saying @dimroc. It was a pragmatic optimization to pre-filter the files being scored by searching for the letters typed in the order they were typed.

This could be handled differently but would require a lot of work to make sure it stays performant. I'll re-open the issue as a placeholder for further discussion.

pysan3 commented 1 year ago

I believe this should be closed as wont-fix due to speed limitations. @cseickel

I did test bunch of algorithms when implementing fuzzy sorter and settled on space separated ands looking at speed vs convince.

We need some kind of language that is faster than lua to achieve better results which is likely never happening.

cseickel commented 1 year ago

We need some kind of language that is faster than lua to achieve better results which is likely never happening.

I agree we can't do more in lua, but there are other options.

I'm thinking that the next step is to integrate with another library for the scoring which delegates the work out to a compiled service, rather than scoring in lua. I think there is an nvim fzf api plugin available now that may do the trick.

rofrol commented 1 year ago

If you want faster language than lua, then I recommend zf written in zig. I already use it with telescope. IMO better than fzf because it prioritizes files over paths.

I use it like this

  {
    "telescope.nvim",
    dependencies = {
      "natecraddock/telescope-zf-native.nvim",
      config = function()
        require("telescope").load_extension("zf-native")
      end,
    },
  },