h4ck3r+=boi v 2.0

  1. Search
  2. About
  3. Subscribe
  4. Archive
  5. Random

h4ck3r+=boi v 2.0

Newer
Older
  • Loading & Handling Vim plugins that require compile time features

    I like playing with vim sometimes. One of the neat features of Vim is that you can compile it with support for other languages (Python, Ruby etc etc). With Vim support for these languages, you can also write plugins, for Vim, in these languages. Without? You have to use VimScript.

    So, if I was to write a Vim plugin, I would do it in Ruby or Python.

    Great. Except these plugins depend on compiling your copy of Vim with these features on in the first place.

    I also use Vim on a lot of different machines: my Linux netbook, my MacBook, various server machines. I want my Vim setup to be portable, so I can use the same setup no matter what machine - and no matter what compiled-in-features are available to me.

    First, I asked on StackOverflow on only load a plugin when Python is enabled:
    if has("python") " code here endif

    Of course, this will work for Ruby, Perl, etc too.

    Now, the question: What to put inside the if statement?

    Background

    Turns out vim has a RUNTIMEPATH environmental variable. RUNTIMEPATH is where vim going looking for plugins. On my OS X machine this is set to ~/.vim, /usr/share/vim/vimfiles and a few other places. Vim will iterate every item of RUNTIMEPATH and look in each folder for plugin directories: autoload/, bundles/, ftdetect/, etc.

    I want to keep a separate directory for all the Vim plugins that depend on a compile time feature. In essence, I want my .vim folder to look like: autoload/ feature_python/ feature_ruby/ feature_perl/ ftdetect/ plugin/ snippets/ syntax/

    As I mentioned before, the feature_python folder includes all the vim plugin folders: $ ls feature_python/ plugin/ ftdetect/ snippets/ syntax/

    Ok, what do I put in my .vimrc file to load these folders?

    if has("python") set rtp^=~/.vim/feature_python/ endif And done!

    Posted on August 15, 2010

  • staff

Field Notes Theme. Designed by Manasto Jones. Powered by Tumblr.