Skip to content
Anton T Johansson edited this page Apr 27, 2019 · 5 revisions

Vim Setup

Requirements

You need a VIM version that has been with Python 2.7 or later (+python or +python3). You can check this from within VIM using :python3 import sys; print(sys.version) (use :python for Python 2).

Installation

  1. Install jedi-vim (or another autocompletion plugin that supports jedi) either manually or using your preferred plugin manager.
  2. Make sure you do not have other autocomplete plugins loaded.
  3. Make sure you have the autocomplete engine working for the native Python libraries.

asciicast

Configuration

Step 1 and 2 will set this for your whole environment, if you want to set this up in a separate virtualenv see section Setting up ironpython-stubs in a virtualenv.

  1. Append the path to the stubs to the PYTHONPATH variable in your shell profile (e.g. .bash_profile/.bashrc/.zshrc) using the command export PYTHONPATH=${PYTHONPATH}:/path/to/iron-python-stubs/release/stubs.min
  2. Put let g:jedi-vim#force_py_version = '2' in your .vimrc if you have Python 3 in your environment.
  3. You are now ready to complete using jedi-vim, the standard keymap is <C>-<Space>. You can use ervandew/supertab to easily map completions to <Tab>.

If you have other libraries you would like to add like rpw, you add multiple paths using a colon. PYTHONPATH=${PYTHONPATH}:/path/to/iron-python-stubs/release/stubs.min:/path/to/revitpythonwrapper.lib

Usage

asciicast

Some additional context for these instructions can be found in this blog post: Autocompletion for Rhino/Grasshopper python scripts in Vim

Setting up ironpython-stubs in a virtualenv

  1. Create a new virtualenv with the command virtualenv -p python2 .venv in your project directory. Replace python2 with the path to your Python 2 executable if python2 doesn't work.
  2. Create a file called .pth in .venv/lib/python2.X/site-packages/ containing the absolute or relative path to the ironpython-stubs. E.g. /path/to/ironpython-stubs/release/stubs.min
  3. source .venv/bin/activate and start editing, jedi-vim will use your virtualenv with the added path to the stubs.
Clone this wiki locally