Giter VIP home page Giter VIP logo

vimpy's Introduction

Vimpy ~ Python auto-import plugin for Vim

  1. Description
  2. Options
  3. Commands
  4. Requirements
  5. Contact

1. Description

Vimpy is a vim-plugin which can be used to (semi) automatically add new import lines to your python scripts. When you run vimpy it will evaluate the line at the cursor position. If it finds any missing / undefined names it will try to automagically resolve what (sub)module(s) is/are missing and add the needed import lines to the top of the python script.

When the import line to be added is in the simple / direct format (eg. import os) impy will not need any help unless it can't find the module in the $PYTHONPATH. Relative imports (eg. from foo import blah) are more tricky. If the relative import is from a module that has already been imported / added as an importline impy should be fine. If it's a new module however vimpy will most likely need some help and (optionally) prompt for the module the relative import is importing from.

Vimpy follows the PEP8 guidelines. Imports are grouped in the following order: stdlib imports, third-party imports and local imports with a blank line between each section and two blank lines after the last importline.

2. Options

This option controls whether impy will ask for help when it cannot resolve a relative import by itself.

let g:vimpy_prompt_resolve = 1

If this option is set vimpy will remove import lines for unused modules.

let g:vimpy_remove_unused = 1

3. Commands

Checks the line at the cursor's position for new imports.

:VimpyCheckLine

4. Requirements

Vimpy relies on 'pyflakes' for its missing import decection magic. This third-party module can be installed using pip or downloaded from pypi: https://pypi.python.org/pypi/pyflakes.

5. Contact

Plugin github page @ http://github.com/dbsr/vimpy

You can contact me at dydrmntion -AT- gmail -DOT- com.

vimpy's People

Contributors

dbsr avatar jasonlvhit avatar

Stargazers

João avatar Dave avatar Zev Averbach avatar Jose Carlos Padial avatar GitFree avatar Hoagy avatar Sergey Safonov avatar Seong Yong-ju avatar Anand avatar Sidnei Pereira avatar Naru avatar Toni Grzinic avatar Michael Truong avatar  avatar Stanislav avatar Jonathan Barratt avatar

Watchers

James Cloos avatar  avatar  avatar

vimpy's Issues

relative imports

I did some digging in your code and unfortunately, when executed, the plugin does not include any local paths in the its search path. Is there a way to get vimpy to see a sys.path that looks more like the sys.path that the program/script has when it is run?

It would be great if there was some way that the user could tell vimpy what the root of the project was and the virtualenv / python version in use. That way vimpy could add the appropriate paths.

Missing module dependencies for python3.7

I am using python3.7 in one my project and wanted to test use this plugin, however right after the installation it shows bunch of errors when i start neovim . Please note I already have pyflakes installed.

  File "/spare/ssd/rbhanot/.config/nvim/plugged/vimpy/ftplugin/python/vimpy/vimpy_.py", line 6, in <module>                                                                                                         
    from StringIO import StringIO                                                                                                                                                                                   
ModuleNotFoundError: No module named 'StringIO' 

Since python37 does not have StringIO module and instead IO from which you can import StringIO, i fixed this issue but then there were even more.

So i guess the plugin is not supported for python37. Any plans ?

Invalid expression error when opening any Python file in Vim 7.4

I just installed vimpy to give it a try, but got an error. I've looked at the code and tried to figure out the cause, but I'm stumped. This is the traceback:

Error detected while processing /home/self/.vim/bundle/vimpy/ftplugin/python/vimpy.vim:
line   28:
Traceback (most recent call last):
File "<string>", line 4, in <module>
vim.error: invalid expression
E121: Undefined variable: let
E15: Invalid expression: let s:have_flake = 0

What's additionally odd is that I have pyflakes installed, so I would expect that line 28 would not get executed.

Just installed, shows a bunch of errors on vim startup

Errors:

Error detected while processing /home/farzeen/.vim/plugged/vimpy/ftplugin/python/vimpy.vim:
line   28:
Traceback (most recent call last):
  File "<string>", line 4, in <module>
vim.error: Vim:E121: Undefined variable: let
line   43:
Traceback (most recent call last):
  File "<string>", line 5, in <module>
  File "/home/farzeen/.vim/plugged/vimpy/ftplugin/python/vimpy/vimpy_.py", line 9, in <module>
    from pyflakes import reporter, api
ImportError: No module named pyflakes

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.