Vim: Difference between revisions

From NixOS Wiki
imported>Fadenb
No edit summary
imported>Mic92
Line 37: Line 37:
* Add your plugin to ./vim-plugin-names
* Add your plugin to ./vim-plugin-names
* Generate via <code>vim-plugin-names-to-nix</code>
* Generate via <code>vim-plugin-names-to-nix</code>
* <del>If plugin needs additional code (for example: some dependencies, extra build steps etc.) then create a pull request to [https://github.com/jagajaga/vim-addon-vim2nix/tree/master/additional-nix-code vim2nix]. That will helps update plugins in the future.</del>(vim2nix 404)


= Real life examples =
= Real life examples =

Revision as of 00:14, 24 August 2017

Vim plugins can be installed with the help of nix. You can omit using vim plugin managers and do everything in your .nixpkgs/config.

Examples

Using VAM as manager

You can add this to you nix configuration to get vim with custom .vimrc and listed plugins.

 vim_configurable.customize {
    name = "vim-with-plugins";
    # add custom .vimrc lines like this:
    vimrcConfig.customRC = ''
      set hidden
      set colorcolumn=80 
    '';
    vimrcConfig.vam.knownPlugins = pkgs.vimPlugins; # optional
    vimrcConfig.vam.pluginDictionaries = [
      # load always
      { name = "youcompleteme"; }
      { names = [ "youcompleteme" "foo" ]; }
      # only load when opening a .php file
      { name = "phpCompletion"; ft_regex = "^php\$"; }
      { name = "phpCompletion"; filename_regex = "^.php\$"; }
      # provide plugin which can be loaded manually:
      { name = "phpCompletion"; tag = "lazy"; }
    ];
  };

Full documentation at VAM homepage.

Using Pathogen as manager

There is a pathogen implementation as well, but its startup is slower and [VAM] has more features.

    vimrcConfig.pathogen.knownPlugins = vimPlugins; # optional
    vimrcConfig.pathogen.pluginNames = [ "vim-addon-nix" "youcompleteme" ];

Adding new plugins

Real life examples

YouCompleteMe

Currently the youcompleteme plugin uses unwrapped clang on linux. This causes it to not find stdlib.h. There is a workaround you can put in your .ycm_extra_conf.py file, which works by executing the C/C++ compiler and getting it to output the list of search paths - which includes the search path to find stdlib.h.