Skip to content
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

Add option to use fzf-lua instead of Telescope #142

Open
akthe-at opened this issue Jun 13, 2024 · 32 comments
Open

Add option to use fzf-lua instead of Telescope #142

akthe-at opened this issue Jun 13, 2024 · 32 comments
Assignees
Labels
enhancement New feature or request regexp branch

Comments

@akthe-at
Copy link

Hello! Long time user of your plugin! Much appreciated all that you do! Recently I transitioned from using some Telescope and some fzf-lua to pretty much entirely fzf-lua. The only exception that I have run into so far is this plugin. I was wondering if you would be open to having some extensibility where a user would be able to choose between using Telescope.nvim or fzf-lua as their picker when using this plugin?

I am open to working on a PR (not saying I am the best candidate but somebody needs to be willing to work for the things they want) but I wanted to check and see if you were willing to entertain the feature idea at all. Ultimately, I would like for the LazyVim distro to be able to more easily allow the freedom for a user to pick between telescope or fzf-lua without it impacting their ability to enjoy all the other core and extra features of the distro.

@linux-cultist
Copy link
Owner

linux-cultist commented Jun 13, 2024

Absolutely! It's been brought up before also with the older version, and I like the idea. So if you work on that feature for the regexp version, I will be more than happy. :)

See if you can also take into account making it work on smaller screens. There is another feature request about that, and basically just having a way to make sure the entire dialog window looks good on smaller screens also.

@akthe-at
Copy link
Author

I have been looking around at the different plugins that offer some mixture of picker/fuzzy finder capability and so far I am leaning towards the approach taken by Neogit

Any thoughts on that? I saw some interesting other approaches but felt like they might be abstracting away a little too much and adding a little more complexity and abstraction than I was thinking would be necessary here.

In review, User config gives options for telescope, or fzf-lua (perhaps mini.pick as well?)( and will modify the behavior based on that. However, no matter which path they take there will also be a vim.ui.select() fallback as well. This was suggested originally by Folke but noticed it was being used in this implementation from Neogit as well.

@linux-cultist
Copy link
Owner

linux-cultist commented Jun 14, 2024

I think it's always good to go for as low complexity as possible, so people can understand it easily. So I think that approach you linked looks clean and nice, so if it seems easy to implement, go for it. :)

Another request from users of VenvSelect is for the viewer (telescope or fzf-lua) to be able to show that a search is running. I played around a bit with this for telescope but it seems that I need to replace the entire telescope viewer when results are done, just to update the title text. And that makes it disappear for a short while, and it looks ugly I think.

So if it's possible to update the header text in fzf-lua to say that a search is running, and update it again when a search is done, it would be great also. It's not essential, just a "nice to have" feature if possible.

Thanks again for your work this!

@folke
Copy link

folke commented Jun 14, 2024

fzf will automatically show a spinner when the search is still running, so nothing really special needed for that :)

@akthe-at
Copy link
Author

fzf will automatically show a spinner when the search is still running, so nothing really special needed for that :)

I spent like 10 minutes looking for that this morning because I knew that fzf had that spinner! ;) I feel like this could easily take me a week or so to work on @folke since lua is not my strong suite yet...I know how fast you move and develop though, if you feel like you would rather budge in front of me and take this, I would not be offended! I also understand if you're too busy as well with the breadth of stuff that you are always working on!

@folke
Copy link

folke commented Jun 14, 2024

I don't use python often, so I'm good, thanks :)

I still believe a basic vim.ui.select implementation first would be better,
since that can then already be used by other pickers.

And probably also easier to implement?

@akthe-at
Copy link
Author

I can agree with that! allows this plugin to be used by anyone regardless if they want to use fzf, telescope, mini.pick, etc. As plugins come and go over time, this would be most extensible and sustainable over time to go that route.

@linux-cultist
Copy link
Owner

Sounds good to me also. I havent tried vim.ui.select, is it possible to still show icons the way telescope does now, and show which venv is active in some way?

@folke
Copy link

folke commented Jun 14, 2024

You're limited to text, but you can of course still use icons.

Prickers that re-implement ui.select, can use the select kind to possibly change how the items look like, so they can do more than just text.

https://neovim.io/doc/user/lua.html#vim.ui.select()

@linux-cultist
Copy link
Owner

Thanks @folke :) Sounds worth exploring and see what can be done with it.

@akthe-at Dont worry if it takes a week or several weeks. There is no big rush to get it finished. I actually have vacation myself soon - im going to Italy for two weeks on June 24:th.

But if you feel like its just too much work, dont hesitate to say so and I will just unassign the task from you. Didnt mean to put any pressure on you. :) If you dont have time or energy, its perfectly OK.

Learning lua takes some time and effort and Im far from an expert in it. The only thing ive written in lua is this plugin. Im more experienced with Python, Go and some Rust.

@akthe-at
Copy link
Author

I think I've made some good progress on this so far but have struggled a little with the concept of incoming search results and vim.ui.select(). It seems like fzf-lua and telescope both handle the updating results as the different search jobs finish but it doesn't feel as intuitive when trying to do it with the builtin.

@linux-cultist
Copy link
Owner

linux-cultist commented Jun 21, 2024

Its really good that you made some progress on it. :) I was a bit worried that the vim.ui.select would not be able to cover the more "advanced" use cases that makes the plugin look and feel a bit nicer for the user.

Maybe we just should add some support for fzf-lua and call it a day. Possibly also add support for vim.ui.select for people who dont want any extra bells and whistles and just want a list of venvs.

I just dont want it to be a maintenance nightmare of debugging 3 different viewers for edge cases... that would quickly take a lot of time away from adding more interesting features to the actual plugin that searches for venvs. But maybe it doesnt add a lot of code to support them.

@linux-cultist linux-cultist changed the title feat request: option to use fzf-lua instead of Telescope Add option to use fzf-lua instead of Telescope Jun 27, 2024
@akthe-at
Copy link
Author

akthe-at commented Jul 6, 2024

Just wanted to update that I did back burner this a little bit over the last few weeks as I prepped another project for production.

I have currently got a rudimentary working proof of concept working. It needs to be tweaked because its a bit funky with spacing of paths/sources...it refreshes awkwardly with new search results, and it doesn't open instantly(it waits for a first set of results or something)...But both telescope and fzf-lua do work interchangeable and the virtual environments are found, can be selected and activated...

@linux-cultist
Copy link
Owner

That's really nice! I'm back on Tuesday next week and can help to test whatever you have by then. :)

@linux-cultist
Copy link
Owner

If you create a PR with code formatted with stylua (there is a stylua.conf in the git repo), I will be happy to play around with it.

@akthe-at
Copy link
Author

@linux-cultist I will do this after I rebase and incorporate the latest changes to the regexp branch. Do you want it to be a draft PR?

My biggest barriers for the fzf-lua implementation...the nice async refreshing/redrawing from Telescope seem like it would happen nicely if fzf-lua was doing the find commands itself but I don't think it can do the multiple different fd commands at once like the search module currently does it. Instead, I tried to have the fzf-lua picker get updated each time a job finished...but it tries to enter into insert mode automatically at the end of this (this results in like 5 different i's being placed into the fzf search bar which obfuscates the results until they are deleted).

The other ways I tried to implement this made it so that no results were shown until the second calling off Venvselect after the first search finished and picker was closed. I had planned on trying to see if I could use the fzf action-reload related functionality in a callback function.

@linux-cultist
Copy link
Owner

Sure, make it a draft PR until we are happy with how it works.

I wonder if we can ask the author of fzf-lua how he would implement async updating, maybe an example we can build on. Because the built-in fzf-lua pickers do async updating, like if you do a search for files for example, the results come in as they are found. So I think its possible, but probably poorly documented. :)

@huwqchn
Copy link

huwqchn commented Jul 15, 2024

Why don't we use vim.ui.select implementation for this?

@linux-cultist
Copy link
Owner

linux-cultist commented Jul 15, 2024

@huwqchn We talked about it a bit further up in this thread. Its worth investigating, but not sure if vim.ui.select can do async updates (update results as they come in from a background search) or show multiple columns so we can show search type and currently selected venv?

From the examples ive seen, its seems its just a simple listbox with no headers?

@akthe-at
Copy link
Author

@huwqchn The problem I kept running into with trying a vim.ui.select implementation is that this plugin has many different fd jobs returning results asynchronously and it seems like vim.ui.select works best as a picker for a one time list. I was not having success with getting a quality updating experience that fed in results as more and more results were returned.

However, I am not saying the limitation isn't 100% a skill issue on my part and I was going about it all wrong!

@akthe-at
Copy link
Author

akthe-at commented Aug 1, 2024

@linux-cultist just wanted to let you know that I didn't give up on this but I did just start over from scratch the other day. Will reopen my draft pr soon (also got a little side tracked building a fence in real life ;) )

@linux-cultist
Copy link
Owner

That's great, thank you! I have been a bit busy with setting up a kubernetes cluster at home and learning about it, so haven't looked at the code yet either. :)

@leikoilja
Copy link

great initiative, guys. really looking forward for this :)
@akthe-at, any progress?

@akthe-at
Copy link
Author

Great question @leikoilja ... Not going to lie, I restarted from scratch, went and did a bunch of research and asked the maintainer of fzflua some questions for it, went on a long vacation doing some camping and hiking, and ever since I got back I have not picked it back up again :(

@linux-cultist
Copy link
Owner

I also haven't thought about this for quite down time, but it would be really cool to get it implemented. I like fzf-lua better myself also but telescope was more convenient when I wrote the plugin.

@akthe-at akthe-at mentioned this issue Sep 22, 2024
4 tasks
@paulkwonsns
Copy link

I also really wish to have venv-selector in fzf-lua. Would it be possible?

@stefanboca
Copy link

stefanboca commented Dec 3, 2024

@linux-cultist Thanks for the great plugin! I was thinking of giving this a go. I have an implementation in mind, but I'd have to change things around a bit.

This is out of scope of this issue, but you can see the changes I've made in my dev branch here. The main change here is reworking the config. None of the changes are strictly necessary (especially some of the internal refactoring, which I was doing more so as a test), but IMHO the config rework makes configuration much more clear. Some of these are breaking changes though, so a new release would probably be in order if they are implemented.
For reference, this is what I imagine the new config to look like:

local config = {
    sysname = nil,
    cache = {
        enabled = true,
        auto_activate = true,
    },
    search = {
        fd_binary = nil,
        enable_default_patterns = true,
        timeout_ms = 5000,
        patterns = {},
    },
    select = {
        picker = "auto",
        show_search_type = true,
        on_result_callback = nil,
        active_venv_color = "#00FF00",
        telescope = {
            filter_type = "substring",
        },
    },
    activate = {
        notify = false,
        require_lsp_activation = true,
        set_env_vars = true,
        activate_in_terminal = true,
        hooks = { hooks.basedpyright_hook, hooks.pyright_hook, hooks.pylance_hook, hooks.pylsp_hook },
        on_activate_callback = nil,
    },
    debug = false,
}

Again, the fzf picker could certainly be implemented without most of these changes, so it's up to you if I should work on these further.

I also have a preliminary implementation of an fzf picker on my fzf branch here. There are a few issues with it so I'll probably start over, but along the same idea. The approach I have in mind would also make it easy to add new pickers (like vim.ui.select, as discussed above).
I'd like to thank @akthe-at for his work in #177, which is the basis for my implementation in this branch.

Please let me know what you think, and then I'll start writing some PRs!

@akthe-at
Copy link
Author

akthe-at commented Dec 3, 2024

@stefanboca I can't speak for @linux-cultist but my hats off to you if you can finish this off. This has sat on my todo list and stared me in the eyes for months now but I have continuously pushed it away! Good luck and I will still try to help out with testing/eyes on this as well in anyway that I can...

@patelharsh9797
Copy link

Any update on this?
I recently switch to fzf for my picker after updating the lazyvim to v14.

@akthe-at
Copy link
Author

@stefanboca lets get the ball rolling on this (together I mean)! Where would you like to direct me to start testing this out/pain points you are having?

@ZachVec
Copy link

ZachVec commented Jan 13, 2025

@linux-cultist plz review #188

@wigging
Copy link

wigging commented Jan 27, 2025

Just want to show my support for using fzf-lua instead of telescope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request regexp branch
Projects
None yet
Development

No branches or pull requests

10 participants