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

Different python version in neovim python3 host and virtualenv python #19

Open
wookayin opened this issue Sep 19, 2018 · 2 comments
Open
Labels
enhancement New feature or request

Comments

@wookayin
Copy link
Contributor

Consider a case where g:python3_host_prog is set to /usr/bin/python (3.5.x), and the current shell (e.g. $PATH) uses another python from virtualenv or anaconda, with different version (3.6.x).

In this case, Syntax from python 3.6+ is not supported. e.g.

   99 var = 1
E>100 print(f'{var}')

Output of :Semshi error is

Syntax error: invalid syntax (100, 14)

Is this a neovim-related issue? Can we configure python being used in code checking other than neovim's host python (or autodetect from $PATH)?

@numirias
Copy link
Owner

Thanks for raising this, I knew someone would eventually do. It's a known limitation which doesn't make it less of a problem though. From the README:

Semshi works with the same syntax version as your Neovim Python 3 provider. This means you can't use Semshi on code that's Python 2-only or uses incompatible syntax features.

Semshi is simply retrieving the AST via Python's ast module which depends on the version of the Python provider which is running the plugin.

But thinking about it, there may be viable workarounds to get AST and symtable via another Python distribution. I'll investigate if it's feasible to e.g. get the information doing IPC with a different Python process (seems like a significant overhead) or cross-import the modules between versions (which sounds like it's going to get messy) and let you know.

wookayin added a commit to wookayin/dotfiles that referenced this issue Sep 20, 2018
Previously, neovim's host python3 is configured in the order of
system python (/usr/local/bin/python3, /usr/bin/python3) and then
local python3 from $PATH (e.g. virtualenv or anaconda). This means
as long as system python exists, it always becomes neovim's host python.

From now, local python3 is more prioritized given that 'neovim' package
is installed (otherwise, use system python as default host python
so that it doesn't force users to have neovim package installed on it).

This will allow us to use local python3 as a neovim's host python
if we want (by installing 'neovim' package), which could be quite
useful in some use cases such as numirias/semshi#19 .
@numirias numirias added the enhancement New feature or request label Sep 23, 2018
@wookayin
Copy link
Contributor Author

wookayin commented Nov 7, 2018

So the current approach I am using (and, what I'd recommend) is to set correct g:python3_host_prog as the path your python interpreter, inside the virtualenv/condaenv. This variable could be set dynamically on neovim startup.

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

No branches or pull requests

2 participants