linux-cultist / venv-selector.nvim

Allows selection of python virtual environment from within neovim
MIT License
379 stars 40 forks source link

Support find instead of fd to reduce dependencies #73

Closed Otterpatsch closed 1 month ago

Otterpatsch commented 8 months ago

Hello,

First of all thank you for the great plugin. Im using it in two scenarios like on my local machine and on some remote machine. For the first everything works like a charm but if im on a remote machine (via ssh) i get the following error:

Which i believe is because fd is not installed (do not got sudo rights)

Error executing Lua callback: .../nvim/lazy/venv-selector.nvim/lua/venv-selector/venv.lua:171: bad argument #1 to 'spawn' (string expected, got nil)
stack traceback:
        [C]: in function 'spawn'
        .../nvim/lazy/venv-selector.nvim/lua/venv-selector/venv.lua:171: in function 'find_parent_venvs'
        .../nvim/lazy/venv-selector.nvim/lua/venv-selector/venv.lua:41: in function 'load'
        ...azy/venv-selector.nvim/lua/venv-selector/mytelescope.lua:183: in function 'open'
        .../nvim/lazy/venv-selector.nvim/lua/venv-selector/init.lua:48: in function <.../nvim/lazy/venv-selector.nvim/lua/venv-selector/init.lua:47>

I use lazy to install the plugin as follows:

return  {
        "linux-cultist/venv-selector.nvim",
        dependencies = {
            "neovim/nvim-lspconfig",
            "nvim-telescope/telescope.nvim",
            "mfussenegger/nvim-dap-python",
        },
        opts = {
            dap_enabled = true, -- makes the debugger work with venv
                        anaconda_base_path = "~/miniconda3/",
                        anaconda_envs_path = "~/miniconda3/envs/",
                        parents = 0,
        },
        keys = {
            {
                "<leader>es", ":VenvSelect<CR>",
                desc = "Select Environment",
            },
        },
}
Otterpatsch commented 8 months ago

So can one replace fd with something like find? I would be fine if its slower. Just dont want to have a another system dependency

linux-cultist commented 8 months ago

Unfortunately not, the plugin uses fd directly right now with specific flags to search for things using regexp etc.

It would probably be possible to do similar things with find, but it's different syntax and flags, and not sure the results would be identical (and if they are not, extra work to adapt the results).

Doesn't feel like a fun thing to spend time on right now, but if you or anyone else wants to make a PR, I will accept it as long as it's bug free. :)

linux-cultist commented 2 months ago

This is supported in the new version of the plugin I'm working on in the regexp branch. You can use any program you want to list the venvs. It's still under development but you can give it a try already if you want.

linux-cultist commented 1 month ago

Closing this since it's supported in the regexp branch. Please try it, although fd is still required for the default searches to work. But if you like, you can write your own queries with find or something else if you like.