Setting up VIM as an IDE for Python

Hans Pinckaers
3 min readAug 21, 2018

--

There are already a lot of posts about VIM setups with Python. This is more an reference post for myself, maybe someone else finds this useful. I will go into detail of some of my plugin settings. Here is a overview of all my plugins, colortheme and font:

  • Neovim 0.3.1
  • Plug plugin manager
  • NCM2 is the best plugin for auto-complete with fuzzy matching, with a small patch applied for extra speed.
  • Jedi-vim for call signatures, documentation, usages and go-to assigments.
  • Tagbar for a nice overview of tags in the file.
  • Impsort for sorting and highlighting of imported functions/classes.
  • FlyGrep for project-wide search.
  • Ctrlp for fuzzy file finding.
  • Commentary for commenting.
  • Airline for a fancy statusline.
  • Lucius (light) pretty black-on-white colortheme.
  • Iosevka Term Medium a programmable typeface.
  • (not VIM related: I use pudb as debugger)

Plugin settings

NCM2 autocomplete plugin

Speedy autocompletion with NCM2 ending with Jedi-vim call signature

After trying a lot of different autocomplete plugins (YouCompleteMe, nvim-completion-manager, asyncomplete, deoplete etc.) I settled with nvim-completion-manager 2, because of the fuzzy matching, reliability with showing up when backspacing, the absense of any flickering and the small codebase.

However, Jedi (the source for Python suggestions in NCM2-jedi) can be quite slow for big libraries like numpy / tensorflow etc. A recent issue (jedi/issues/1116) made me aware that inspecting certain attributes of the suggestions (e.g. ‘type’ and ‘description’) is slow for big libraries. The initial fetching of suggestions themselves is quite fast. Commenting out the parts of NCM2-jedi (see my fork) where these attributes of the suggestions are accessed speeds up autocompletion by seconds. For me, plain suggestions for code completions without type information is fine. Since I use jedi-vim for documentation and go-to assignment I can safely remove the fetching of type information. See my issue here ncm2/ncm2-jedi/issues/6. If you want even more speed you can trade some accuracy by using my hacky fork of jedi.

Jedi-vim

Jedi is awesome, and I love this plugin especially for the call-signatures above functions (see gif above). Since I have NCM2 for autocompletion I disabled all of jedi-vim’s autocomplete functionality in my .vimrc:

Theme: Lucius

I use the low-contrast light theme of Lucius with a background color of #E2E2E2 (terminal setting) and these extra python highlights (possible because of ImpSort):

Font: Iosevka Term Medium

I really like this font, since a lot can be customized to your taste. You can download some default options from the website be5invis.github.io/Iosevka but for me the default was a bit too narrow. I changed these lines in the parameters file to make the font thicker. I also needed to shift the powerline characters a bit for perfect aligment:

Everything in one .vimrc

My full .vimrc can be found here or below. I know it is quite big, but maybe you can find some nice settings in there. If you have any tips or suggestions let me know!

--

--

Hans Pinckaers

MD doing a PhD applying Deep Learning to Computational Pathology at Radboudumc.