vim-gf-python icon indicating copy to clipboard operation
vim-gf-python copied to clipboard

Support for relative imports

Open guyzmo opened this issue 8 years ago • 1 comments

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…

guyzmo avatar Mar 23 '16 15:03 guyzmo

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')).

guyzmo avatar Mar 23 '16 15:03 guyzmo