vim-gf-python
vim-gf-python copied to clipboard
Support for relative imports
For relative imports, gf resolves an import statement such as:
from .common.exceptions import MyException
into:
/common/exceptions
and then vim yells saying that it cannot find /common/exceptions, because obviously it cannot be found at the filesystem's root ☺.
A patch would be to resolve the path before looking up the module, so that it gets translated to:
$VIM_PWD/$BUFFER_DIR_PATH/common/exceptions
where $VIM_PWD is the path to where vim is living, and $BUFFER_DIR_PATH is the path to the current buffer's file.
I'll try to figure out a patch for that…
the PR #5 works for me.
And, BTW, if $BUFFER_DIR_PATH (which is basically expand('%')) is absolute, I'm not prepending $VIM_PWD (which is expand('$PWD')).