Please complete these steps and check these boxes (by putting an x inside
the brackets) _before_ filing your issue:
vim --version.:YcmDebugInfo.:YcmToggleLogs command.install.py (or cmake/make/ninja) including its invocationThank you for adhering to this process! It ensures your issue is resolved
quickly and that neither your nor our time is needlessly wasted.
I don't understand one thing. When I have unit tests in my project in directory tests and I refer to my module by relative path eg:
from ...MyModule import MyClass
I can easily use YCM for jumping for references from my unit tests.
But when I run my tests from the parent directory this way:
python -m tests.mymodule
I should be using absolute paths so I include my module in my unit tests this way:
from MyModule import MyClass
However, I can't see this is supported by YCM because after this I cannot jump to the definition of MyClass from my unittest.
Am I missing something here? I'm really sorry if I missed something in the documentation.
That's because when running the tests with python -m tests.mymodule, you are adding the current directory (your project directory) to the Python path but Jedi (the semantic engine used by YCM for Python) is not aware of that. A solution is to add that path to the PYTHONPATH environment variable inside Vim and restart YCM:
:let $PYTHONPATH="/path/to/project/directory"
:YcmRestartServer
Thanks, that helps.
Is there a way to automate this in ~/.vimrc file when running?
Ok. This is what I was looking for:
let $PYTHONPATH .= getcwd()
Looks like you solved it. Closing :)