-
Notifications
You must be signed in to change notification settings - Fork 52
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: native (vim.ui.select
) and fzf-lua pickers
#188
base: regexp
Are you sure you want to change the base?
Conversation
file This is to make it easier to add new pickers Additionally, the entrypoint of search has changed from `search.New` to `gui.open`, because `run_search` is now passed a picker object
...and allow automatically detecting installed pickers. When no supported pickers are found, fall back to "native" picker, which uses `vim.ui.select` (not yet implemented).
Unfortunately, there is no refresh functionality because afaik `vim.ui.select` doesn't support it.
I installed telescope.nvim to test this PR out so the problem could be in my setup but when trying to search with picker = "telescope" and using the ctrl+r search refresh, I was hit with this error msg: Error 05:09:34 msg_show.emsg E5108: Error executing lua: ...s/venv-selector.nvim/lua/venv-selector/gui/telescope.lua:44: attempt to call field 'run_search' (a nil value)
stack traceback:
...s/venv-selector.nvim/lua/venv-selector/gui/telescope.lua:44: in function 'key_func'
...hare/nvim/lazy/telescope.nvim/lua/telescope/mappings.lua:293: in function <...hare/nvim/lazy/telescope.nvim/lua/telescope/mappings.lua:292>
|
When using picker = "fzf-lua", if I activate a virtual env with venv-selector, it works just great...if I try to activate the same venv again that is currently activated ( now green in the picker) I get hit with this error: Info 05:13:55 notify.info VenvSelect Registered '/home/aktheat/projects/fe_str/.venv/bin/python' with basedpyright LSP.
Error 05:14:01 notify.error [Fzf-lua] fn_selected threw an error: ...jects/venv-selector.nvim/lua/venv-selector/gui/utils.lua:134: attempt to index local 'entry' (a nil value)
stack traceback:
...heat/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/core.lua:242: in function '__index'
...jects/venv-selector.nvim/lua/venv-selector/gui/utils.lua:134: in function 'select'
...cts/venv-selector.nvim/lua/venv-selector/gui/fzf-lua.lua:24: in function 'action'
...t/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/actions.lua:117: in function 'act'
...heat/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/core.lua:148: in function 'fn_selected'
...heat/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/core.lua:235: in function <...heat/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/core.lua:234>
[C]: in function 'xpcall'
...heat/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/core.lua:234: in function <...heat/.local/share/nvim/lazy/fzf-lua/lua/fzf-lua/core.lua:226> This does not occur if you select a different venv. Edt: This also does not happen if you are using the native picker |
Nice job @stefanboca ...This is way better implemented then I was ever able to come close to. I think you've done some great stuff here. I dug in quickly and found a few items that might need to be fixed up/polished up. I will keep using this PR as my daily driver and see if I can find anything else. I did not review the actual code itself yet! |
7b9e449
to
a4f5489
Compare
@akthe-at I believe I've fixed the issues you've mentioned. Could you verify? |
c50d437
to
fde607d
Compare
fzf strips ansi color codes from the output, so the output returned by fzf and the key in `self.entries` were different.
fde607d
to
e7b8c42
Compare
I can confirm my issues were resolved with the latest commits, 100% fire. Nice Job! |
That's great to hear! Please let me know if you run into any more issues. |
Looks like some great progress! I will try the code also as daily driver for a few days. :) |
This is awesome! Looking forward to this addition! It might also be worth adding official snacks.picker support as well now that that is out and growing in popularity. Currently just using the native picker works well with it but it would be cool to get pretty formatting |
Hi! This is great! I'm running LazyVim with fzf-lua, without telescope and my setup is copied from lazyvim extras python lang setup with the exception of the venv-selection portion:
|
I think this is related to the #187. |
Closes #142
This PR implements a new native picker (using
vim.ui.select
) andfzf-lua
picker. The picker can be manually selected via thepicker
config option, or by default is automatically selected based on what is installed (by settingpicker = "auto"
), with a fallback on the native picker if neither telescope or fzf-lua are available.Some notes:
native
picker only shows results once the search is done, and without color. AFAIK these are both limitations of the api.fzf-lua
picker only sorts and deduplicates results once the search is done. This might result in some flickering, but I'm not sure if there's an elegant solution to sorting/dedup wile the search is live. This isn't really an issue for quick searches because only the final results are displayed.show_telescope_search_type
,on_telescope_result_callback
, andtelescope_active_venv_color
I'm also open to changing the format for results. Currently, the native picker looks like this:
![image](https://private-user-images.githubusercontent.com/45266795/400119072-ee335d80-1440-4f3b-ac24-422ab6dc4eeb.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5Njg1MzAsIm5iZiI6MTczODk2ODIzMCwicGF0aCI6Ii80NTI2Njc5NS80MDAxMTkwNzItZWUzMzVkODAtMTQ0MC00ZjNiLWFjMjQtNDIyYWI2ZGM0ZWViLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA3VDIyNDM1MFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTdjMmQ0MjM3NzAzNWNhNDFhOWEyMmMzNTlmY2QzOGZiNzA4ZTk2YmMwODJhODY1ZmQ0NzYxNDcwOGFkM2EwMWYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.P_T3tYoaoEVUj5DUFrBKp7aPk4Uu0tHdySJclUY2f-w)
![image](https://private-user-images.githubusercontent.com/45266795/400119195-90c3f21d-d126-4d7b-9c53-0ef8938a0a22.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5Njg1MzAsIm5iZiI6MTczODk2ODIzMCwicGF0aCI6Ii80NTI2Njc5NS80MDAxMTkxOTUtOTBjM2YyMWQtZDEyNi00ZDdiLTljNTMtMGVmODkzOGEwYTIyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA3VDIyNDM1MFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTk3MWEzMWRhM2E0MzAzNDQzMTdlODY2OGE2YWQwYWMyOTQ5YTMxYzA4MTE5MmM4NDM4M2UzNzU2OTkwYjRjNjYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.r7hFVWtMvI0PvXfejZ-9pi5EmYzxHbhm53il0vlz1qQ)
and the fzf picker looks like this:
(with
show_telescope_search_type
enabled)Please feel free to make suggestions and let me know what you think!
cc @akthe-at