linux-cultist / venv-selector.nvim

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

Cannot find correct Python execution path under Miniconda with empty string for anaconda python_parent_dir #79

Closed LeihanChen closed 7 months ago

LeihanChen commented 7 months ago

Hi,

Thank you for sharing such a great and convenient plugin for us. Unfortunately I had difficulty to use it correctly under my Ubuntu 20.04 and miniconda. Here is my configuration in LazyVim:

return {
  "linux-cultist/venv-selector.nvim",
  dependencies = { "neovim/nvim-lspconfig", "nvim-telescope/telescope.nvim", "mfussenegger/nvim-dap-python" },
  opt = {
    enable_debug_output = true,
    dap_enabled = true, -- Enable DAP integration.
    anaconda = { python_parent_dir = "" },
    anaconda_base_path = "~/miniconda3",
    anaconda_envs_paths = "~/miniconda3/envs",
    search = false,
  },
  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>" },
  },
}

However, the miniconda paths that venv-selector found is incorrect, which is shown in following screenshots:

venu-selector 屏幕截图 2023-11-23 180138

The real python interpreter path should be inside .../Miniconda3/envs/my_env_name/python.exe, even although I already set anaconda = { python_parent_dir = "" } but i do not understand why there is still extra folder path /lib/python3.7/venv after anaconda_envs_paths. Meanwhile I also set enable_debug_output = true, to print debug info. Unfortunately when I type `:messages' still I cannot find any debug info. Is there anything incorrect for my setting?

Sorry for my configuration question as a new Lua and Neovim user.

Best, Leihan

mennohofste commented 7 months ago

In case you have not found the answer yet, you misspelled opt -> opts in the table. What you are seeing is the default config, since opts is not changed.

As a sidenote, if you are using LazyVim, not to be confused with lazy.nvim, then the following configuration should do what you want. In LazyVim you do not need to redefine dependencies and keys if you are not changing them.

return {
  "linux-cultist/venv-selector.nvim",
  opts = function(_, opts)
    if require("lazyvim.util").has("nvim-dap-python") then
      opts.dap_enabled = true
    end

    return vim.tbl_deep_extend("force", opts, {
      anaconda_base_path = "$HOME/miniconda3",
      anaconda_envs_path = "$HOME/miniconda3/envs",
      parents = 0,
    })
  end,
}

This is just a slightly altered default config, see: https://www.lazyvim.org/extras/lang/python#venv-selectornvim

linux-cultist commented 7 months ago

Thank you @mennohofste. I had planned to start to look at this issue but I have managed to attract a really bad man cold over here, so haven't been at my computer for a week or so.

Hopefully your solution fixes the issue.

LeihanChen commented 7 months ago

@mennohofste Thank you for the instructions with details for me to understand my issues. Perfectly work.

@linux-cultist Hopefully you recovers fully. Again, really appreciate your plugin and support. Will close this issue.