linux-cultist / venv-selector.nvim

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

Struggle With Hooks configuration #88

Closed febridev closed 5 months ago

febridev commented 6 months ago

on this hooks configuration that is optional or mandatory? because after switch vitrual env :VenvSelect my library still suggest error doesn't import

image
mennohofste commented 6 months ago

If you are using Pyright, Pylance, or pylsp, it should work out of the box. What error are you getting? What venv manager are you using?

febridev commented 6 months ago

after choose the venv I didn't get anything and library already install on venv still got error on current python file

mennohofste commented 6 months ago

What venv manager are you using?

What is your config?

linux-cultist commented 6 months ago

@febridev, can you provide the info @mennohofste asked for?

febridev commented 5 months ago

I only using pip @mennohofste

this my config

local venv_status, venv_selector = pcall(require, "venv-selector")
if not venv_status then
        return
end

venv_selector.setup({
        dependencies = { "neovim/nvim-lspconfig", "nvim-telescope/telescope.nvim", "mfussenegger/nvim-dap-python" },
        event = "VeryLazy",
})
venv_selector.get_active_path()
venv_selector.get_active_venv()
venv_selector.retrieve_from_cache()
mennohofste commented 5 months ago

pip is a package manager, not a venv manager. How do you create virtual environments? What command do you run?

Furthermore, it seems you are using lazy.nvim; however, you are not calling the setup function correctly. The setup function of venv-selector does not have dependencies, nor event keys.

I think it is easiest if you read the README thoroughly, as well as the lazy.nvim documentation.

For reference, this is what a lazy.nvim configuration should look like:

return {
  'linux-cultist/venv-selector.nvim',
  dependencies = { 'neovim/nvim-lspconfig', 'nvim-telescope/telescope.nvim', 'mfussenegger/nvim-dap-python' },
  config = function()
    require('venv-selector').setup {
      -- Your options go here
      -- name = "venv",
      -- auto_refresh = false
    }
  end,
  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>' },
  },
}
febridev commented 5 months ago

I using this command for create virtual env virtualenv my-env and for nvim I use .lua file

febridev commented 5 months ago

this issue already solved I reset my configuration on neovim + packer