Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Behave different with quite nvim activate virtual env and enter the nvim! #28

Open
meicale opened this issue Jan 19, 2024 · 9 comments
Open

Comments

@meicale
Copy link

meicale commented Jan 19, 2024

Behave differently with quite nvim activate virtual env and enter the nvim!
I used this plugin to change used virtual env on the fly when run shell command directly in neovim. It works and it can find the right python bin. But the editor can not notice that changes. The diagnostic tools still complains the wrong things. Does anyone know how to solve this? Thanks!

@AckslD
Copy link
Owner

AckslD commented Jan 19, 2024

Hi @meicale, probably dependent on how you configure your diagnostic tools?

@Klvxn
Copy link

Klvxn commented Nov 28, 2024

Any update on this? I've observed the same thing.

@AckslD
Copy link
Owner

AckslD commented Nov 28, 2024

I would need some more details to be able to help here, it does work for me

@Klvxn
Copy link

Klvxn commented Nov 28, 2024

  • when venv is activated before launching neovim.
    "Go to Declaration" on a class or function from third party package, takes you to package in the activated virtual env

  • Activating with swenv.
    "Go to Declaration" takes you to the system wide installed package.

And I noticed in your update_path function, the PATH variable gets updated with ~/project/venv/bin which works as expected for Linux/Mac. I run Windows and .../venv/bin doesn't exist. .../venv/scripts is for Windows

@AckslD
Copy link
Owner

AckslD commented Nov 29, 2024

I see, I don't know how venvs work on windows. On UNIX systems it's sufficient to update PATH. What would be the corresponding action on windows?

@Klvxn
Copy link

Klvxn commented Dec 2, 2024

Yeah, updating PATH is sufficient but your implementation updates the wrong venv_path for Windows.

I manually changed the update_path function to this and it works as it should.

local update_path = function(path)
    vim.fn.setenv('PATH', path .. '/Scripts' .. ';' .. ORIGINAL_PATH)
    -- /Scripts instead of /bin
end

The lsp now opens packages installed in the activated virtual environment.

It's like I said before, you initially used venv_path/bin to update the PATH variable. But on Windows, it's venv_path/Scripts
The Scripts dir is where the python executable is located.

@AckslD
Copy link
Owner

AckslD commented Dec 22, 2024

Thanks @Klvxn! Would you like to open a PR which fixes this with your update_path if you're on windows?

@Klvxn
Copy link

Klvxn commented Dec 22, 2024

Okay I just went through previous PRs and someone already opened one for the same exact purpose (#43 ). So, I'd simply just leave a review of the changes the person made if that's okay?

@AckslD
Copy link
Owner

AckslD commented Dec 23, 2024

Oh right thanks for pointing that out, it had completely slipped my mind

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants