linux-cultist / venv-selector.nvim

Allows selection of python virtual environment from within neovim
MIT License
442 stars 46 forks source link

[Feature request]: Multiple backends for visual picker #55

Closed TroySigX closed 4 months ago

TroySigX commented 1 year ago

I notice that venv-selector only uses Telescope as its visual picker. It would be great if it migrate to something more general, like vim.ui.select, that way, users can choose between different pickers like nui.nvim or fzf-lua.

linux-cultist commented 1 year ago

I agree and I'm actually using fzf-lua myself for most pickers, but couldn't find a good example how to populate a picker.

But I would welcome PR's or even links to good docs. Telescope was just the easiest to get started with.

TroySigX commented 1 year ago

Hmm, I'm not very proficient with lua, but I found this via :h vim.ui.select:

select({items}, {opts}, {on_choice})                         *vim.ui.select()*
    Prompts the user to pick from a list of items, allowing arbitrary
    (potentially asynchronous) work until `on_choice`.

    Example: >lua

     vim.ui.select({ 'tabs', 'spaces' }, {
         prompt = 'Select tabs or spaces:',
         format_item = function(item)
             return "I'd like to choose " .. item
         end,
     }, function(choice)
         if choice == 'spaces' then
             vim.o.expandtab = true
         else
             vim.o.expandtab = false
         end
     end)
<

    Parameters: ~
      • {items}      (table) Arbitrary items
      • {opts}       (table) Additional options
                     • prompt (string|nil) Text of the prompt. Defaults to
                       `Select one of:`
                     • format_item (function item -> text) Function to format
                       an individual item from `items`. Defaults to
                       `tostring`.
                     • kind (string|nil) Arbitrary hint string indicating the
                       item shape. Plugins reimplementing `vim.ui.select` may
                       wish to use this to infer the structure or semantics of
                       `items`, or the context in which select() was called.
      • {on_choice}  (function) ((item|nil, idx|nil) -> ()) Called once the
                     user made a choice. `idx` is the 1-based index of `item`
                     within `items`. `nil` if the user aborted the dialog.
TroySigX commented 1 year ago

Would using dressing.nvim solve your problem? It has the telescope option here

linux-cultist commented 4 months ago

I dont think I will add support for a different viewer. It would not be so hard to do since in the new regexp version, the GUI code is very small and self-contained. But I dont know this area very well and I rather focus on the core plugin.

But if anyone wants to contribute a PR, feel free to do so!