summaryrefslogtreecommitdiff
path: root/nvim/default.nix
blob: c1b66cf90d3260e3f79fd906a930d6a4b8fde662 (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
60
61
62
63
64
65
66
67
68
69
70
71
{}: rec {

  pkgs = (import ../pkgs.nix).stable2305 {};

  misspell = pkgs.buildGoPackage rec {
    pname = "misspell";
    version = "0.3.4";
    goPackagePath = "github.com/client9/misspell";

    src = pkgs.fetchFromGitHub {
      owner = "client9";
      repo = "misspell";
      rev = "v${version}";
      sha256 = "1vwf33wsc4la25zk9nylpbp9px3svlmldkm0bha4hp56jws4q9cs";
    };

    goDeps = ./misspellDeps.nix;
  };

  env = pkgs.buildEnv {
    name = "nvim-env";
    paths = [
      pkgs.shellcheck
      misspell
    ];
  };

  envPlugins = "${env}/share/vim-plugins";

  init = pkgs.writeText "nvim-init" ''
    source ${pkgs.vimPlugins.vim-plug}/plug.vim

    call plug#begin()
    Plug '${pkgs.vimPlugins.deoplete-nvim}'
    Plug '${pkgs.vimPlugins.nerdtree}', { 'on':  'NERDTreeToggle' }
    Plug '${pkgs.vimPlugins.nerdtree-git-plugin}'
    Plug '${pkgs.vimPlugins.vim-gitgutter}'
    Plug '${pkgs.vimPlugins.neomake}'
    Plug '${pkgs.vimPlugins.papercolor-theme}'
    Plug '${pkgs.vimPlugins.vim-go}', { 'for': 'go' }
    Plug '${pkgs.vimPlugins.vim-nix}', { 'for': 'nix' }
    Plug '${pkgs.vimPlugins.rust-vim}', { 'for': 'rust' }
    call plug#end()

    source ${./init.vim}
  '';

  nvimRaw = pkgs.writeScriptBin "nvim" ''
    #!${pkgs.bash}/bin/bash
    export PATH=${env}/bin:$PATH
    exec ${pkgs.neovim}/bin/nvim -u ${init} "$@"
  '';

  rplugin = pkgs.stdenv.mkDerivation {
    name = "nvim-rplugin";
    buildInputs = [ pkgs.git pkgs.tree nvimRaw ];
    builder = builtins.toFile "builder.sh" ''
      source $stdenv/setup
      mkdir -p "$out"/
      export NVIM_RPLUGIN_MANIFEST="$out"/rplugin.vim
      nvim -i NONE -c ':UpdateRemotePlugins' -c ':exit' >/dev/null
    '';
  };

  nvim = pkgs.writeScriptBin "nvim" ''
    #!${pkgs.bash}/bin/bash
    export NVIM_RPLUGIN_MANIFEST=${rplugin}/rplugin.vim
    exec ${nvimRaw}/bin/nvim "$@"
  '';

}