-
Notifications
You must be signed in to change notification settings - Fork 15
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
Feat/add option to use fzf #209
base: main
Are you sure you want to change the base?
Conversation
Awesome!❤ I noticed it shows a preview on most commands, which it shouldnt do. But you're definitely on to something! |
sorry had no time to work on this. changed job and fully occupied wrapping my head around that |
Dont worry about it. Always a lot to take in when changing jobs, good luck! |
picking up this again. do you mind sharing your on_package_selected for nuget fzf? hate to do extra work if not needed 😂 |
should be in the config function? picker = 'telescope' -- 'fzf', 'mini.picker', 'snacks.picker' ? |
on_package_selected for nuget fzf, this one? ---@param cb function
local function fzf_nuget_search(cb)
fzf.fzf_live('dotnet package search <query> --format json | jq ".searchResult | .[] | .packages | .[] | .id"', {
fn_transform = function(line) return line:gsub('"', ""):gsub("\r", ""):gsub("\n", "") end,
actions = {
["default"] = function(selected)
local package = selected[1]
cb(package)
end,
},
})
end |
Yeah let's start with fzf and think about others later. |
pretty sure the callback is this from the nuget.lua file |
Ah my bad I see, the on_package_selected should have an fzf-lua implementation for selecting the version. Sorry I do not have. Could probably write one quickly if you need it? |
i reused the add_package and seems to work just fine but did not test against secrets as i didn't configure it. |
b42cab0
to
2bda8ac
Compare
i'm still thinking maybe it would make sense to select picker in the config? right now it is hit and miss in the if else clause in pickers/init.lua |
Oh yeah definitely add it to options |
Maybe something like picker = "telescope" | "fzf" | nil where nil picks whatever is installed or throws an error if neither is found? |
Yes that is exactly in line with what I thought of. I'll look into it as soon as I can get some time to get the secret previewer working. The picker works but previewer is just giving nil right now. |
It's also worth considering how this will be to maintain. Say a fresh contributor makes a PR implementing some new feature. Would they make fzf and telescope pickers. Should it be co-located in some way to make it easier to update both at the same time. They kinda have to stay in sync |
How do you feel about removing the need to use telescope/fzf-lua altogether. make it optional and use vim.ui.select for the things that don't need a preview and only optionally use fzf-lua or telescope? |
The thought has crossed my mind before. My main reasons for not doing it is
Im not against it, Im just not convinced its worth spending time on, what do you think? |
The picker and pick_sync is pretty straight forward to implement. For the migration and preview_pickers it is not possible to get a preview so it may not be needed. I can push an update to this PR where all pickers are implemented for telescope, fzf and plain vim.ui.select. Take a look at it and try it out? it does need some cleaning up though lol. |
Sure |
remove comment
remove comment fix typo
remove comment fix typo cleanup comments
I was thinking maybe just use vim.ui.select for the simple pickers that don't need preview, picker and pick_sync. No need to add extra overhead by extra implementation of those. For secrets and migrations we implement optional fzf/telescope? For nuget fzf works best among the three. Well try them all three and I’ll adjust according to your input |
Just tested this, amazing work! We could do default Thoughts? Other than that AWESOME WORK, this is an amazing PR! |
Glad you liked it 😁. Yeah need to add something to the docs too but we need to decide how to address the picker selection first. Now I am starting to lean towards removing it from the options again and just do local has_telescope = pcall(require, ”telescope”)
local has_fzf = pcall(require, ”fzf-lua”)
if has_telescope then
…
elseif has_fzf then
…
else use_base
end This way it does not effect existing users and it will fallback to using vim.ui.select for users not using either. We should put telescope and fzf as optional dependencies and remove telescope in the dependencies section in the examples? |
One thing we should take into account is users who have telescope because it is required by a plugin and fzf because they prefer it. I think it belongs in the options. As for removing the dependency on telescope, I dont think its a good idea IMO. telescope or FZF will give you a way better experience than vim.ui.select. So for the "superusers" its nice to support vim.ui.select but for people who are just configuring the plugin with no options I would like telescope to be default. We can update the readme to reflect that telescope is an optional plugin but we should still keep it in the dep array in the example Yeah JQ has been used internally for some functions for a while, kinda just forgot to add it to readme. But it should be there |
Alright! I'll make the adjustments as soon as I get back home. |
- Telescope is default picker - If options.picker is set but dependency is not fulfilled, notify user that the plugin is falling back to basic picker
Please have a look at it. I added a notification if picker is misconfigured, I hope you agree it makes sense. |
Refactored picker and added fzf-lua picker
Optionally use fzf-lua or telescope
@GustavEikaas apologies, it is really quick and dirty and not working for fzf-lua just yet but would like to get some feedback on the principle