Ⅰ. 插件描述
Vim go to module support for python files.Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'tudorprodan/pyfinder-vim'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'tudorprodan/pyfinder-vim'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'tudorprodan/pyfinder-vim'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/tudorprodan/pyfinder.vim
Ⅳ. 文档说明
# pyfinder.vim
Version 0.1
Jump to source file for python import statements.
What it does
1 minute presentation video here.
from django.contrib.admin.models import UserPlace the cursor on the above line, type<leader>gs
vim opens a new buffer with .venv/lib/python2.7/site-packages/django/contrib/admin/models.py
Installation
To install the plugin, just drop the plugin folder to your dotvim directory.
There are currently no configuration options available, so no need to edit your config file.
You can now use <leader>gs to jump to the source of your import statement.
For now, you need a version of vim with python bindings. This will no longer be required in the future.
Look out for the version numer on top, when it changes, update your plugin.
Using pathogen
Just clone the project in your bundles directory.
git clone git://github.com/tudorprodan/pyfinder.vim.git /path/to/.vim/bundle/
Supported paths
Currently, the plugin finds python modules in the following order:
- as a relative path to the current file
- as a relative path to the project root (current directory)
- as an absolute path to any of the virtualenv packages (if
$VIRTUAL_ENVis set, by the activate script) - as an absolute path to any system module
Implementation
This plugin DOES NOT run any of the python modules it searches for.
Instead it searches by hand in the python paths.
It doesn't use imp, pkgutil, or anything else, as all of them import either the target module or their parents when fetching paths.
Limitations
The plugin currently uses Vim's Python bindings, and doesn't work without them.
However, the only real piece of python code that needs to be ran is at plugin-load to determine all system package paths. So it can be rewritten in full VimL in order to be usable on versions compiled with -python.
Plans for the future
I plan to implement the following features, but I just haven't had time to yet.
- customizable bindings,
CtrlPstyle.let g:pyfinder_map - more commands to open in: new tab, split, vertical split
VimLreimplementation. I have implemented it inPythonto make sure it's useful and usable. There are no limitations why it could not be rewritten inVimL- command to refresh with a new project root
- command to add a virtualenv
- project config file to be read, to allow more custom python package setups
Contributing
Please feel free to contribute.
I'm quite new to writing Vim plugins, I'm sure there's a lot of stuff that can be improved.
If you find an issue, please post it in the issue tracker.
Thanks!