Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

FZF/fzf-lua support (or generic datasource provider for other pickers) #25

Closed
megalithic opened this issue Oct 11, 2021 · 20 comments · Fixed by #97
Closed

FZF/fzf-lua support (or generic datasource provider for other pickers) #25

megalithic opened this issue Oct 11, 2021 · 20 comments · Fixed by #97
Labels
enhancement New feature or request help wanted Extra attention is needed result-provider

Comments

@megalithic
Copy link

Love this! I imagine that since you don't use fzf-lua you'd likely not want to spend time adding support. I haven't dove deep into this repo yet, so forgive me if this already exists.. would you be willing to add some sort of provider so that other pickers might be used?

Thanks!

(PS. I'd be interested in adding fzf-lua support if you were up for having that added)

@mrjones2014
Copy link
Owner

I've not used fzf-lua but I'm open to adding support for it. I would gladly merge a PR if you submit one!

@mrjones2014
Copy link
Owner

Basically you run the rust backend via bin/dash-nvim query1 query2 query3, if using a non-standard path to Dash.app you can do bin/dash-nvim -c path/to/Dash.app query1 query2 query3 and the Rust backend returns a JSON array.

@megalithic
Copy link
Author

This is brilliant; thank you @mrjones2014 !

@mrjones2014
Copy link
Owner

@megalithic also, you can get the path to the rust backend binary via vim.g.dash_root_dir .. require('dash.constants').dash_nvim_bin_path, and the path to Dash.app is in config, require('dash.utils.config').config.dash_app_path.

@megalithic
Copy link
Author

@mrjones2014 are you good with me responding with a warning to the user if no telescope is installed, versus the explicit requirement of it defined in plugin/dash.vim (also, documenting this added benefit of being able to call the rust binary directly and build your own provider code?

@mrjones2014
Copy link
Owner

@megalithic yeah you'll need to remove the hard requirement on telescope. make sure to update lua/dash/health.lua as well.

We should check if we have either telescope or fzf-lua installed, and if neither are installed, then throw an error. You can check if it's installed without erroring using Lua's pcall. Example usage here:

local telescope_ok, _ = pcall(require, 'telescope')

@mrjones2014
Copy link
Owner

also, documenting this added benefit of being able to call the rust binary directly and build your own provider code?

ah, yeah, on second thought, maybe we shouldn't require either, and instead just offer the full path to the Rust binary as a constant added to dash.constants module.

@mrjones2014
Copy link
Owner

@megalithic this will likely require some refactoring of the Telescope module, and how data is fed into it. Feel free to add me on Discord if you need to chat about it. My Discord ID is Michael Scarn, FBI#5789

@mrjones2014
Copy link
Owner

Actually, now that I think about it, we might not need to. All the interaction with the Rust backend is pretty much handled in lua/dash/utils/jobs.lua. You should be able to just use that module to get the JSON, then do whatever you need to with it to pipe it into fzf-lua.

In your PR, though, can you move lua/dash/utils/telescope.lua to a new module, lua/dash/providers/telescope.lua, and put your fzf-lua provider at lua/dash/providers/fzf-lua.lua?

@megalithic
Copy link
Author

Thanks tons for teh feedback on this. I'm hoping to hunker down and tinker with this over the next week or so (about to head out on a work trip, so won't get as much time on it as i'd want).

@mrjones2014
Copy link
Owner

No problem, I added a --pretty-print option to the Rust backend which might be helpful for debugging.

@mrjones2014
Copy link
Owner

@megalithic one more note, even if we don't require Telescope, we will still require Plenary to run the actual Rust backend. I experimented on this branch with exposing a Lua API directly to the Rust backend but I haven't been able to get it working.

https://github.com/mrjones2014/dash.nvim/tree/matjones/37-rust-remote-plugin

@mrjones2014
Copy link
Owner

@megalithic see #51 -- this will likely make this issue a lot simpler. It exposes a Lua API directly for the Rust backend.

@mrjones2014
Copy link
Owner

@megalithic see also #61

@megalithic
Copy link
Author

Thank you @mrjones2014 !

@mrjones2014
Copy link
Owner

Excited to see how this plugin evolves when more fuzzy-finder providers like fzf/fzf-lua are added!

@mrjones2014
Copy link
Owner

@megalithic backend API has changed again slightly, see #80 and latest docs.

@mrjones2014
Copy link
Owner

@megalithic any timeline on getting a PR together for this? It would be cool to decouple this from telescope so we can reach more users.

if you don’t have time I might start taking a whack at this.

@mrjones2014
Copy link
Owner

I've got a rough start here but idk what I'm doing really with fzf-lua's API

https://github.com/mrjones2014/dash.nvim/tree/matjones/25-fzf-lua-support

@mrjones2014
Copy link
Owner

@megalithic fzf-lua is now supported! 😄

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request help wanted Extra attention is needed result-provider
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants