Giter Site home page Giter Site logo

vim-gf-python's Introduction

Goto File for Python

This is a simple utility to improve vim's standard goto file gf mapping in python. It can find most things, but not all.

It iterates through python's sys.path and looks for modules where one would typically expect to find them.

For example:

  • gf on os finds os.py.
  • gf on email.base64mime finds email/base64mime.py.
  • gf on sqlite3 finds sqlite3/__init__.py.

It does not find more complicated relationships like os.path.

I have a solution to find things like os.path, but the implementation could be considered unsafe. It would involve attempting to import it, and so depending on what one tries to find, it could be dangerous as the code would in effect be evaluated.

vim-gf-python's People

Contributors

blueyed avatar mkomitee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vim-gf-python's Issues

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…

Support for py3k

Two things need to be changed to support py3k:

  1. check feature python3 instead of python
  2. use python3 <<<EOF heredoc instead of python <<<EOF heredoc

I'm not sure how to make the plugin work for both python version...

Find files for targets that are on imported modules

I have a solution to find things like os.path, but the implementation could be considered unsafe. It would involve attempting to import it, and so depending on what one tries to find, it could be dangerous as the code would in effect be evaluated.

You could use the AST standard module for this. You wouldn't be evaluating the code, but rather only parsing it.

If I have time I'll create a pull request adding a part of this feature.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.