0

I use nvim and Mason to manage the lsp server pyright.
and just set pyright.setup{} and don't set any options.

local lspconfig = require("lspconfig")
lspconfig.pyright.setup{}

Because I usually switch python2 and python3, I install pyenv to manage python versions.
I found use pyenv local command cannot make pyright recognize the correct python.
Then I saw the issue https://github.com/neovim/nvim-lspconfig/issues/717.
It said local file cannot be recognized is normal, but pyenv shell and pyenv activate should be recognize.

But for me, both of two ways cannot work.

my-python2 created by pyenv virtualenv 2.7.18 my-python2 command

enter image description here

enter image description here

using print a still reporting an error. And using pyenv activate is the same error

echo $PATH

/Users/xxxx/.pyenv/shims:/Library/Frameworks/Python.framework/Versions/3.12/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin

So I want to know why cannot work fine like the git issue.
And how I can work fine when I exec pyenv shell or pyenv activate

1 Answer 1

0

Its really weird. I suggest you to try nvim-lspconfig with a basic setup. So you can follow the last comment on the thread you had mention:

vim.env.PYENV_VERSION = vim.fn.system('pyenv version'):match('(%S+)%s+%(.-%)')

it works fine for me.

Or at least pyenv shell <venv-name> should work. Try to check the LSP health too using :checkhealth lsp inside neovim.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.