-
-
Notifications
You must be signed in to change notification settings - Fork 370
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
get_project ignores project config #1040
Comments
Update from the future: that patch up there doesn't apply cleanly, and shouldn't be necessary, but something still seems off with my setup. I'm going to check for configuration issues on my end. |
Okay, the configuration works fine. What I'm not sure about is the intended behavior. I'm just going to put my thoughts in here because I'm really confused, and maybe it will illuminate something. When I trigger completion, that eventually results in a call to Because Should the default project's The diff that makes my current problems go away is diff --git a/pythonx/jedi_vim.py b/pythonx/jedi_vim.py
index b140668..c815929 100644
--- a/pythonx/jedi_vim.py
+++ b/pythonx/jedi_vim.py
@@ -239,13 +239,16 @@ def get_project():
environment_path = vim_environment_path
if vim_project_path in ("auto", "", None):
- project_path = jedi.get_default_project().path
+ project = jedi.get_default_project()
+ project_path = project.path
+ added_sys_path = vim_added_sys_path + [path for path in project.added_sys_path if path not in vim_added_sys_path]
else:
project_path = vim_project_path
+ added_sys_path = vim_added_sys_path
project = jedi.Project(project_path,
environment_path=environment_path,
- added_sys_path=vim_added_sys_path)
+ added_sys_path=added_sys_path)
_current_project_cache = cache_key, project
return project But this probably will do the wrong thing for more involved configurations, or maybe it'll burn me in some other context. Anyway, I'm still not sure how the |
Sorry for taking so long to answer. I have had this opened in the browser, but forgot about it. I just realized that this is a bit special, because So I'm happy to merge your patch, but I feel like at the same time it is also questionable that |
Issue
I have a project that I'm attempting to migrate from another editor to vim, and part of what I want to set up is jedi completion and go-to-definition for several nested python projects. I have created a
.jedi/project.json
file in the repository root, that definesadded_sys_path
entries for the sub-projects, as well as some stub files I wrote for third-party code.When I attempt to jump between sub-projects, jedi cannot find the definitions of classes etc.
This appears to be because the
added_sys_path
entries are not present in the project returned fromget_project
.The
JediLoadProject
command does load a properly configured project, but under a non-matching key, soget_project
overwrites it.It appears that
get_project
creates aProject
object with the correctpath
, but ignoring the actual data on disk.I have currently worked around this using the following patch:
This patch gives me the expected behavior noted below, and appears to work correctly in my actual project.
EDIT: On reflection, it probably makes more sense to use
Project.load
in the else branch, but I don't think I hit that, so I left it basically the same.Steps to reproduce
.jedi/project.json
file that contains[1, {"path": ".", "added_sys_path": ["some/junk"]}]
.:pythonx import jedi_vim; print(jedi_vim.get_project().added_sys_path)
.[]
instead of['some/junk']
Output of “:verbose JediDebugInfo”
Jedi-vim debug information
jedi-vim version
Global Python
Using Python version 3 to access Jedi.
/home/maxchase/.pyenv/versions/nvim/bin/python
3.9.1 (default, Dec 31 2020, 10:49:22), [GCC 9.3.0]
/home/maxchase/.pyenv/versions/3.9.1/lib/python3.9/site.py
Jedi
/home/maxchase/.local/share/nvim/site/pack/mwchase/start/jedi-vim/pythonx/jedi/jedi/__init__.py
Jedi environment: <SameEnvironment: 3.9.1 in /home/maxchase/.pyenv/versions/3.9.1>
/home/maxchase/.pyenv/versions/3.9.1/lib/python39.zip
/home/maxchase/.pyenv/versions/3.9.1/lib/python3.9
/home/maxchase/.pyenv/versions/3.9.1/lib/python3.9/lib-dynload
/home/maxchase/.pyenv/versions/nvim/lib/python3.9/site-packages
Known environments
Settings
:version
:messages
:scriptnames
The text was updated successfully, but these errors were encountered: