[Nix-dev] system wide .vimrc / managing plugins the nix way - proposal and implementation

Marc Weber marco-oweber at gmx.de
Sun Oct 26 22:36:22 CET 2014


Well - it might be desirable - but for other users vim should be the way
they know it - plain simple stupid. Thus forcing a customized vim
behavior on other people is could be a pain.

The first step for letting the users choose is
- create nix code creating .vimrc files
- create vim wrappers which use them, eventually having a different name

This patch implements this:
  http://mawercer.de/tmp/vim-patch

More than that VAM (vim-addon-manager) got a autoload/nix.vim file which
can turn github based plugins (known by vim-pi) into nix derivations.

I'm not sure I should call myself of being a maintainer of anything
within nix, its just what I think will provide greatest value with least
effort. This change was driven by the discussion found here:
https://github.com/jagajaga/nixpkgs/commit/0b9432d5e22fc5453e0b4265ca36d5015cbcaf1c#commitcomment-8305911

The perfect fix (creating a huge package cross language/tool packagce
database) would be a lot more work, putting all vim plugins into nixpkgs
(> 5.000 - a lot are no longer used) would be overkill. Thus this
attempt tries to follow the cabal2nix like approach making packaging 
plugins people use easier while supporting enhancements such as
addon-info.json files introduced by VAM containing simple unversioned
dependency information.

The result looks like this illustrating how much the unversioned
dependency management of VAM can simplify your setup:

    # test cases:
    test_vim_with_vim_addon_nix_using_vam = vim_configurable.customize {
      name = "vim-with-vim-addon-nix-using-vam";
      vimrcConfig.vam.plugins = [
        {name = "vim-addon-nix"; }
      ];
    };
  
    test_vim_with_vim_addon_nix_using_pathogen = vim_configurable.customize {
      name = "vim-with-vim-addon-nix-using-pathogen";
      vimrcConfig.pathogen.plugins = map (x: vimPlugins.${x}) [
        # target package:
        "vim-addon-nix"
        # dependencies:
        "vim-addon-completion" "vim-addon-goto-thing-at-cursor"
        "vim-addon-mw-utils" "vim-addon-actions" "vim-addon-errorformats" "tlib"
      ];
    };

The depeendency magic is provided by a dependencies = ["name1" "name2"]
attr in vimPlugins.

Please note that all features provided by VAM's vam#Scripts() function
are supported such as loading plugins lazily triggered by you opening
some special particular filetype.

Because pathogen and VAM are supported (sorry no Vundle/ NeoBundel
support yet) this should please the majority. Pathogen has no advantage
over VAM AFAIK - I just added it for completness and because the
discussion mentioned above asked for it.

This mail is for gathering feedback, I'll create a pull request soon.

Marc Weber


More information about the nix-dev mailing list