summary refs log tree commit diff
path: root/modules/vim.nix
blob: dbe052b7caa78fcedd43ce1fb802e816d1381746 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
{
  lib,
  pkgs,
  auxiliaryPkgs,
  ...
}:

let
  configs = [
    ../configs/.vimrc
    ../configs/plugins.vimrc
  ];

  configVars = {
    "@ycm_extra_conf@" = ../configs/.ycm_extra_conf.py;
  };

  processRCFile =
    f:
    with builtins;
    (replaceStrings
      (lib.attrNames configVars)
      (map toString (lib.attrValues configVars))
      (readFile f));

  customRC = builtins.foldl' (r: f: r + (processRCFile f)) "" configs;

  vim-configured =
    with pkgs;
    vim-full.customize {
      name = "vim"; # explicitly replace vim

      vimrcConfig = {
        inherit customRC;

        packages.collection = with vimPlugins; {
          start = [
            fzf-vim
            vim-fugitive
            vim-gitgutter
            vim-easymotion
            vim-sleuth
            vim-better-whitespace
            vim-tmux-navigator
          ] ++ (with auxiliaryPkgs; [ youcompleteme ]);

          opt = [ ];
        };
      };
    };

in
{
  programs.vim = {
    defaultEditor = true;

    package = vim-configured;
  };
}