linux-cultist / venv-selector.nvim

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

Unable to view/select python 3 versions #112

Closed ehxactly closed 1 month ago

ehxactly commented 2 months ago

Hey all,

The plugin is installed and working, however, it is only listing Python 2* versions.

Wondering how to resolve this as I have python 3.12.1 installed and 3.12.2 in the same /versions/ directory where the python 2* are.

Unsure why they aren't appearing in the UI?

return {
  'linux-cultist/venv-selector.nvim',
  dependencies = { 'neovim/nvim-lspconfig', 'nvim-telescope/telescope.nvim', 'mfussenegger/nvim-dap-python' },
  opts = {
    -- Your options go here
    name = "venv",
    auto_refresh = true
  },
  event = 'VeryLazy', -- Optional: needed only if you want to type `:VenvSelect` without a keymapping
  keys = {
    -- Keymap to open VenvSelector to pick a venv.
    { '<leader>vs', '<cmd>VenvSelect<cr>' },
    -- Keymap to retrieve the venv from a cache (the one previously used for the same project directory).
    { '<leader>vc', '<cmd>VenvSelectCached<cr>' },
  },
}

image

ehxactly commented 2 months ago

Now, I am seeing:

image

When I select 3.12.2, nothing happens and when I run :VenvCurrentSelect it shows nothing is selected...

linux-cultist commented 2 months ago

I'm working on a new version of the plugin where you can use regular expressions to filter out exactly the venvs you want to see yourself.

The current version is hard to maintain since supporting all the different venv managers was done by changing the code, and it has become a bit of a mess.

If you want to try the work-in-progress version, you can grab the branch called regexp, and look in the Readme for that branch for a quick example how to configure. It all boils down to using fd with a regexp to filter out exactly what you want to see in the telescope viewer.

So if you know how to use fd, you know how to use the new version of the plugin, basically.

linux-cultist commented 1 month ago

I think you should try the regexp branch now, since im pretty sure it will pick up all your .pyenv pythons without any configuration even. It looks in ~/.pyenv/versions by default and will list all pythons there.

Configuration for lazy.nvim:

return {
  "linux-cultist/venv-selector.nvim",
    dependencies = {
      "neovim/nvim-lspconfig", 
      "mfussenegger/nvim-dap", "mfussenegger/nvim-dap-python", --optional
      { "nvim-telescope/telescope.nvim", branch = "0.1.x", dependencies = { "nvim-lua/plenary.nvim" } },
    },
  lazy = false,
  branch = "regexp", -- This is the regexp branch, use this until its merged with the main branch later
  config = function()
      require("venv-selector").setup()
    end,
    keys = {
      { ",v", "<cmd>VenvSelect<cr>" },
    },
},

It should list only pythons under the bin directory as well, so a lot of the "wrong" pythons wont show up.

linux-cultist commented 1 month ago

Can you try the regexp version and see if it finds the correct venvs?

linux-cultist commented 1 month ago

Closing this since it should work in the regexp branch, and if it doesn't, reopen the issue. Thank you!