blob: d6d4a9420181203d982930ac015d33079d8a0185 (
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
{
pkgs ? (import ../pkgs.nix) {},
}: rec {
goimports = pkgs.buildGoModule rec {
pname = "goimports";
version = "v0.1.7";
src = builtins.fetchGit {
url = "https://go.googlesource.com/tools";
rev = "0df0ca0f43117120bd7cc900ebf765f9b799438a";
};
vendorSha256 = "1vs4vbl3kh8lbqrm4yqqn27ammlqj7jdbi0ca9s4fkja2sk45ibi";
subPackages = [ "cmd/goimports" ];
};
# the gocode-gomod which comes with nixpkgs places the binary at
# gocode-gomod, we gotta rename it
gocode = pkgs.stdenv.mkDerivation {
name = "gocode";
src = pkgs.gocode-gomod;
builder = builtins.toFile "builder.sh" ''
source $stdenv/setup
mkdir -p "$out"/bin/
cp "$src"/bin/gocode-gomod "$out"/bin/gocode
'';
};
env = pkgs.buildEnv {
name = "nvim-env";
paths = [
pkgs.vimPlugins.vim-plug
pkgs.vimPlugins.deoplete-nvim
pkgs.vimPlugins.deoplete-go
pkgs.vimPlugins.nerdtree
pkgs.vimPlugins.nerdtree-git-plugin
pkgs.vimPlugins.vim-gitgutter
pkgs.vimPlugins.neomake
pkgs.vimPlugins.papercolor-theme
pkgs.vimPlugins.vim-go
pkgs.vimPlugins.vim-nix
pkgs.golangci-lint
pkgs.gopls
gocode
goimports
];
};
envPlugins = "${env}/share/vim-plugins";
init = pkgs.writeText "nvim-init" ''
source ${envPlugins}/vim-plug/plug.vim
call plug#begin('${envPlugins}')
Plug '${envPlugins}/deoplete-nvim'
Plug '${envPlugins}/deoplete-go', { 'for': 'go' }
Plug '${envPlugins}/nerdtree', { 'on': 'NERDTreeToggle' }
Plug '${envPlugins}/nerdtree-git-plugin'
Plug '${envPlugins}/vim-gitgutter'
Plug '${envPlugins}/neomake'
Plug '${envPlugins}/papercolor-theme'
Plug '${envPlugins}/vim-go', { 'for': 'go' }
Plug '${envPlugins}/vim-nix', { 'for': 'nix' }
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 nvimRaw ];
builder = builtins.toFile "builder.sh" ''
source $stdenv/setup
mkdir -p "$out"/
export NVIM_RPLUGIN_MANIFEST="$out"/rplugin.vim
nvim -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 "$@"
'';
}
|