Skip to content
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

Support for relative imports #4

Open
guyzmo opened this issue Mar 23, 2016 · 1 comment · May be fixed by #5
Open

Support for relative imports #4

guyzmo opened this issue Mar 23, 2016 · 1 comment · May be fixed by #5

Comments

@guyzmo
Copy link

guyzmo commented Mar 23, 2016

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 guyzmo linked a pull request Mar 23, 2016 that will close this issue
@guyzmo
Copy link
Author

guyzmo commented Mar 23, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant