Closed xrayw closed 5 years ago
But I just tested it on Mac, Need some test on Windows and Linux.
On windows, usually named python, instead of python3. 😅
Now I'm use the code
sys.platform.lower() == 'darwin'
to determine mac platform and only change on Mac.
Could you try jedi.get_default_environment()
? I prefer jedi.get_default_environment
if it works for you.
But the option 'ncm2_jedi#python_version' could invalid when using jedi.get_default_environment()
??
But the option 'ncm2_jedi#python_version' could invalid when using jedi.get_default_environment() ??
ncm2_jedi#python_version
only decides the python2/python3 process that runs jedi.
Unfortunately this causes some confusion. But It is not designed to decide target completion version.
However, My local test shows that when running python2, jedi.get_default_environment()
gets python2, when running python3, it gets python3. I'm not sure how much ncm2_jedi#python_version
affects jedi library behavior. Therefore I left ncm2_jedi#python_version
configurable.
En.... But how about the pull request? pull request #16
@UzimakiNaruto Thanks for pointing it out. I forgot that change there.
@Guzzii I think #16 should be revered,
When a virtual env or conda env is activated, its python executable path is placed to the first position in $PATH.
Since jedi doc says that jedi.get_default_environment()
handles virtualenv automatically.
jedi.get_default_environment()[source] Tries to return an active Virtualenv. If there is no VIRTUAL_ENV variable set it will return the latest Python version installed on the system. This makes it possible to use as many new Python features as possible when using autocompletion and other functionality.
I'm not sure how it goes with conda. But since we have many types of environment and there's no way to generalize, it's a better idea to stick to jedi's default. Use g:ncm2_jedi#environment
for customization.
@roxma I agree. Users can always rely on g:ncm2_jedi#environment
to set the python executable. It is true even after #16.
@UzimakiNaruto raised a valid point. With #16, it wouldn't pick up python executable named by explicit version. However, the reason why jedi._compatibility.which('python')
didn't return /usr/local/bin/python3
is because /usr/local/bin/python3
was installed by Homebrew, which is a not environment manager, and as a result has to rely on explicit name to differentiate. I feel like in these type of situations, g:ncm2_jedi#environment
is the answer.
Please test #19
It works fine for me.
I found the error on Mac,