1{ lib, stdenv
2, python, cmake, meson, vim, ruby
3, which, fetchFromGitHub, fetchgit, fetchurl, fetchzip
4, llvmPackages, rustPlatform
5, xkb-switch, fzf, skim, stylish-haskell
6, python3, boost, icu, ncurses
7, ycmd, rake
8, gobject-introspection, glib, wrapGAppsHook
9, substituteAll
10, languagetool
11, Cocoa, CoreFoundation, CoreServices
12, buildVimPluginFrom2Nix
13
14# coc-go dependency
15, go
16
17# deoplete-khard dependency
18, khard
19
20# vim-go dependencies
21, asmfmt, delve, errcheck, godef, golint
22, gomodifytags, gotags, gotools, go-motion
23, gnused, reftools, gogetdoc, gometalinter
24, impl, iferr, gocode, gocode-gomod, go-tools
25
26# direnv-vim dependencies
27, direnv
28
29# vCoolor dependency
30, gnome3
31}:
32
33self: super: {
34
35 vim2nix = buildVimPluginFrom2Nix {
36 pname = "vim2nix";
37 version = "1.0";
38 src = ./vim2nix;
39 dependencies = with super; [ vim-addon-manager ];
40 };
41
42 # Mainly used as a dependency for fzf-vim. Wraps the fzf program as a vim
43 # plugin, since part of the fzf vim plugin is included in the main fzf
44 # program.
45 fzfWrapper = buildVimPluginFrom2Nix {
46 pname = "fzf";
47 version = fzf.version;
48 src = fzf.src;
49 };
50
51 skim = buildVimPluginFrom2Nix {
52 pname = "skim";
53 version = skim.version;
54 src = skim.vim;
55 };
56
57 LanguageClient-neovim = let
58 version = "0.1.156";
59 LanguageClient-neovim-src = fetchurl {
60 url = "https://github.com/autozimu/LanguageClient-neovim/archive/${version}.tar.gz";
61 sha256 = "0bf2va6lpgw7wqpwpfidijbzphhvw48hyc2b529qv12vwgnd1shq";
62 };
63 LanguageClient-neovim-bin = rustPlatform.buildRustPackage {
64 name = "LanguageClient-neovim-bin";
65 src = LanguageClient-neovim-src;
66
67 cargoSha256 = "1w8g7pxwnjqp9zi47h4lz2mcg5daldsk5z72h8cjj750wng8a82c";
68 buildInputs = stdenv.lib.optionals stdenv.isDarwin [ CoreServices ];
69
70 # FIXME: Use impure version of CoreFoundation because of missing symbols.
71 # Undefined symbols for architecture x86_64: "_CFURLResourceIsReachable"
72 preConfigure = stdenv.lib.optionalString stdenv.isDarwin ''
73 export NIX_LDFLAGS="-F${CoreFoundation}/Library/Frameworks -framework CoreFoundation $NIX_LDFLAGS"
74 '';
75 };
76 in buildVimPluginFrom2Nix {
77 pname = "LanguageClient-neovim";
78 inherit version;
79 src = LanguageClient-neovim-src;
80
81 propagatedBuildInputs = [ LanguageClient-neovim-bin ];
82
83 preFixup = ''
84 substituteInPlace "$out"/share/vim-plugins/LanguageClient-neovim/autoload/LanguageClient.vim \
85 --replace "let l:path = s:root . '/bin/'" "let l:path = '${LanguageClient-neovim-bin}' . '/bin/'"
86 '';
87 };
88
89 clang_complete = super.clang_complete.overrideAttrs(old: {
90 # In addition to the arguments you pass to your compiler, you also need to
91 # specify the path of the C++ std header (if you are using C++).
92 # These usually implicitly set by cc-wrapper around clang (pkgs/build-support/cc-wrapper).
93 # The linked ruby code shows generates the required '.clang_complete' for cmake based projects
94 # https://gist.github.com/Mic92/135e83803ed29162817fce4098dec144
95 # as an alternative you can execute the following command:
96 # $ eval echo $(nix-instantiate --eval --expr 'with (import <nixpkgs>) {}; clang.default_cxx_stdlib_compile')
97 preFixup = ''
98 substituteInPlace "$out"/share/vim-plugins/clang_complete/plugin/clang_complete.vim \
99 --replace "let g:clang_library_path = '' + "''" + ''" "let g:clang_library_path='${llvmPackages.clang.cc.lib}/lib/libclang.so'"
100
101 substituteInPlace "$out"/share/vim-plugins/clang_complete/plugin/libclang.py \
102 --replace "/usr/lib/clang" "${llvmPackages.clang.cc}/lib/clang"
103 '';
104 });
105
106 direnv-vim = super.direnv-vim.overrideAttrs(oa: {
107 preFixup = oa.preFixup or "" + ''
108 substituteInPlace $out/share/vim-plugins/direnv-vim/autoload/direnv.vim \
109 --replace "let s:direnv_cmd = get(g:, 'direnv_cmd', 'direnv')" \
110 "let s:direnv_cmd = get(g:, 'direnv_cmd', '${lib.getBin direnv}/bin/direnv')"
111 '';
112 });
113
114 clighter8 = super.clighter8.overrideAttrs(old: {
115 preFixup = ''
116 sed "/^let g:clighter8_libclang_path/s|')$|${llvmPackages.clang.cc.lib}/lib/libclang.so')|" \
117 -i "$out"/share/vim-plugins/clighter8/plugin/clighter8.vim
118 '';
119 });
120
121 coc-go = super.coc-go.overrideAttrs(old: {
122 preFixup = ''
123 substituteInPlace "$out"/share/vim-plugins/coc-go/src/utils/tools.ts \
124 --replace 'const cmd = `GOPATH=''${gopath}; go ''${args}`' 'const cmd = `GOPATH=''${gopath}; ${go}/bin/go ''${args}`'
125 '';
126 });
127
128 # Only official releases contains the required index.js file
129 # NB: Make sure you pick a rev from the release branch!
130 coc-nvim = buildVimPluginFrom2Nix rec {
131 pname = "coc-nvim";
132 version = "2020-01-05";
133 src = fetchFromGitHub {
134 owner = "neoclide";
135 repo = "coc.nvim";
136 rev = "984779f2f825626aa9d441746d8b4ee079137c65";
137 sha256 = "0w7qnhi7wikr789h3w5p59l8wd81czpvbzbdanf8klf9ap4ma3yg";
138 };
139 };
140
141 command-t = super.command-t.overrideAttrs(old: {
142 buildInputs = [ ruby rake ];
143 buildPhase = ''
144 rake make
145 rm ruby/command-t/ext/command-t/*.o
146 '';
147 });
148
149 cpsm = super.cpsm.overrideAttrs(old: {
150 buildInputs = [
151 python3
152 stdenv
153 cmake
154 boost
155 icu
156 ncurses
157 ];
158 buildPhase = ''
159 patchShebangs .
160 export PY3=ON
161 ./install.sh
162 '';
163 });
164
165 ctrlp-cmatcher = super.ctrlp-cmatcher.overrideAttrs(old: {
166 buildInputs = [ python ];
167 buildPhase = ''
168 patchShebangs .
169 ./install.sh
170 '';
171 });
172
173 defx-nvim = super.defx-nvim.overrideAttrs(old: {
174 dependencies = with super; [ nvim-yarp ];
175 });
176
177 deoplete-fish = super.deoplete-fish.overrideAttrs(old: {
178 dependencies = with super; [ deoplete-nvim vim-fish ];
179 });
180
181 deoplete-go = super.deoplete-go.overrideAttrs(old: {
182 buildInputs = [ python3 ];
183 buildPhase = ''
184 pushd ./rplugin/python3/deoplete/ujson
185 python3 setup.py build --build-base=$PWD/build --build-lib=$PWD/build
186 popd
187 find ./rplugin/ -name "ujson*.so" -exec mv -v {} ./rplugin/python3/ \;
188 '';
189 });
190
191 deoplete-khard = super.deoplete-khard.overrideAttrs(old: {
192 dependencies = [ self.deoplete-nvim ];
193 passthru.python3Dependencies = ps: [ (ps.toPythonModule khard) ];
194 meta = {
195 description = "Address-completion for khard via deoplete";
196 homepage = "https://github.com/nicoe/deoplete-khard";
197 license = stdenv.lib.licenses.mit;
198 maintainers = with stdenv.lib.maintainers; [ jorsn ];
199 };
200 });
201
202 ensime-vim = super.ensime-vim.overrideAttrs(old: {
203 passthru.python3Dependencies = ps: with ps; [ sexpdata websocket_client ];
204 dependencies = with super; [ vimproc-vim vimshell-vim super.self forms ];
205 });
206
207 forms = super.forms.overrideAttrs(old: {
208 dependencies = with super; [ super.self ];
209 });
210
211 ghcid = super.ghcid.overrideAttrs(old: {
212 configurePhase = "cd plugins/nvim";
213 });
214
215 gist-vim = super.gist-vim.overrideAttrs(old: {
216 dependencies = with super; [ webapi-vim ];
217 });
218
219 gruvbox-community = buildVimPluginFrom2Nix {
220 pname = "gruvbox-community";
221 version = "2019-05-31";
222 src = fetchFromGitHub {
223 owner = "gruvbox-community";
224 repo = "gruvbox";
225 rev = "e122091dad968a5524f3e8136615a479c7b6f247";
226 sha256 = "1hncjyfi1gbw62b2pngy5qxyzibrhbyzgfmm9a58sdh1272l8ls8";
227 };
228 meta.maintainers = with stdenv.lib.maintainers; [ minijackson ];
229 };
230
231 meson = buildVimPluginFrom2Nix {
232 inherit (meson) pname version src;
233 preInstall = "cd data/syntax-highlighting/vim";
234 meta.maintainers = with stdenv.lib.maintainers; [ vcunat ];
235 };
236
237 ncm2 = super.ncm2.overrideAttrs(old: {
238 dependencies = with super; [ nvim-yarp ];
239 });
240
241 ncm2-jedi = super.ncm2-jedi.overrideAttrs(old: {
242 dependencies = with super; [ nvim-yarp ncm2 ];
243 passthru.python3Dependencies = ps: with ps; [ jedi ];
244 });
245
246 ncm2-ultisnips = super.ncm2-ultisnips.overrideAttrs(old: {
247 dependencies = with super; [ ultisnips ];
248 });
249
250 fzf-vim = super.fzf-vim.overrideAttrs(old: {
251 dependencies = [ self.fzfWrapper ];
252 });
253
254 sved = let
255 # we put the script in its own derivation to benefit the magic of wrapGAppsHook
256 svedbackend = stdenv.mkDerivation {
257 name = "svedbackend-${super.sved.name}";
258 inherit (super.sved) src;
259 nativeBuildInputs = [ wrapGAppsHook ];
260 buildInputs = [
261 gobject-introspection
262 glib
263 (python3.withPackages(ps: with ps; [ pygobject3 pynvim dbus-python ]))
264 ];
265 preferLocalBuild = true;
266 installPhase = ''
267 install -Dt $out/bin ftplugin/evinceSync.py
268 '';
269 };
270 in
271 super.sved.overrideAttrs(old: {
272 preferLocalBuild = true;
273 postPatch = ''
274 rm ftplugin/evinceSync.py
275 ln -s ${svedbackend}/bin/evinceSync.py ftplugin/evinceSync.py
276 '';
277 meta = {
278 description = "synctex support between vim/neovim and evince";
279 };
280 });
281
282
283 vimshell-vim = super.vimshell-vim.overrideAttrs(old: {
284 dependencies = with super; [ vimproc-vim ];
285 });
286
287 vim-addon-manager = super.vim-addon-manager.overrideAttrs(old: {
288 buildInputs = stdenv.lib.optional stdenv.isDarwin Cocoa;
289 });
290
291 vim-addon-actions = super.vim-addon-actions.overrideAttrs(old: {
292 dependencies = with super; [ vim-addon-mw-utils tlib_vim ];
293 });
294
295 vim-addon-async = super.vim-addon-async.overrideAttrs(old: {
296 dependencies = with super; [ vim-addon-signs ];
297 });
298
299 vim-addon-background-cmd = super.vim-addon-background-cmd.overrideAttrs(old: {
300 dependencies = with super; [ vim-addon-mw-utils ];
301 });
302
303 vim-addon-completion = super.vim-addon-completion.overrideAttrs(old: {
304 dependencies = with super; [ tlib_vim ];
305 });
306
307 vim-addon-goto-thing-at-cursor = super.vim-addon-goto-thing-at-cursor.overrideAttrs(old: {
308 dependencies = with super; [ tlib_vim ];
309 });
310
311 vim-addon-mru = super.vim-addon-mru.overrideAttrs(old: {
312 dependencies = with super; [ vim-addon-other vim-addon-mw-utils ];
313 });
314
315 vim-addon-nix = super.vim-addon-nix.overrideAttrs(old: {
316 dependencies = with super; [
317 vim-addon-completion
318 vim-addon-goto-thing-at-cursor
319 vim-addon-errorformats
320 vim-addon-actions
321 vim-addon-mw-utils tlib_vim
322 ];
323 });
324
325 vim-addon-sql = super.vim-addon-sql.overrideAttrs(old: {
326 dependencies = with super; [ vim-addon-completion vim-addon-background-cmd tlib_vim ];
327 });
328
329 vim-addon-syntax-checker = super.vim-addon-syntax-checker.overrideAttrs(old: {
330 dependencies = with super; [ vim-addon-mw-utils tlib_vim ];
331 });
332
333 vim-addon-toggle-buffer = super.vim-addon-toggle-buffer.overrideAttrs(old: {
334 dependencies = with super; [ vim-addon-mw-utils tlib_vim ];
335 });
336
337 vim-addon-xdebug = super.vim-addon-xdebug.overrideAttrs(old: {
338 dependencies = with super; [ webapi-vim vim-addon-mw-utils vim-addon-signs vim-addon-async ];
339 });
340
341 vim-bazel = super.vim-bazel.overrideAttrs(old: {
342 dependencies = with super; [ vim-maktaba ];
343 });
344
345 vim-codefmt = super.vim-codefmt.overrideAttrs(old: {
346 dependencies = with super; [ vim-maktaba ];
347 });
348
349 vim-easytags = super.vim-easytags.overrideAttrs(old: {
350 dependencies = with super; [ vim-misc ];
351 });
352
353 # change the go_bin_path to point to a path in the nix store. See the code in
354 # fatih/vim-go here
355 # https://github.com/fatih/vim-go/blob/155836d47052ea9c9bac81ba3e937f6f22c8e384/autoload/go/path.vim#L154-L159
356 vim-go = super.vim-go.overrideAttrs(old: let
357 binPath = lib.makeBinPath [
358 asmfmt
359 delve
360 errcheck
361 go-motion
362 go-tools
363 gocode
364 gocode-gomod
365 godef
366 gogetdoc
367 golint
368 gometalinter
369 gomodifytags
370 gotags
371 gotools
372 iferr
373 impl
374 reftools
375 ];
376 in {
377 postPatch = ''
378 ${gnused}/bin/sed \
379 -Ee 's@"go_bin_path", ""@"go_bin_path", "${binPath}"@g' \
380 -i autoload/go/config.vim
381 '';
382 });
383
384 vim-grammarous = super.vim-grammarous.overrideAttrs(old: {
385 # use `:GrammarousCheck` to initialize checking
386 # In neovim, you also want to use set
387 # let g:grammarous#show_first_error = 1
388 # see https://github.com/rhysd/vim-grammarous/issues/39
389 patches = [
390 (substituteAll {
391 src = ./patches/vim-grammarous/set_default_languagetool.patch;
392 inherit languagetool;
393 })
394 ];
395 });
396
397 vim-hier = super.vim-hier.overrideAttrs(old: {
398 buildInputs = [ vim ];
399 });
400
401 vim-isort = super.vim-isort.overrideAttrs(old: {
402 postPatch = ''
403 substituteInPlace ftplugin/python_vimisort.vim \
404 --replace 'import vim' 'import vim; import sys; sys.path.append("${python.pkgs.isort}/${python.sitePackages}")'
405 '';
406 });
407
408 vim-metamath = super.vim-metamath.overrideAttrs(old: {
409 preInstall = "cd vim";
410 });
411
412 vim-snipmate = super.vim-snipmate.overrideAttrs(old: {
413 dependencies = with super; [ vim-addon-mw-utils tlib_vim ];
414 });
415
416
417 vim-wakatime = super.vim-wakatime.overrideAttrs(old: {
418 buildInputs = [ python ];
419 });
420
421 vim-xdebug = super.vim-xdebug.overrideAttrs(old: {
422 postInstall = false;
423 });
424
425 vim-xkbswitch = super.vim-xkbswitch.overrideAttrs(old: {
426 patchPhase = ''
427 substituteInPlace plugin/xkbswitch.vim \
428 --replace /usr/local/lib/libxkbswitch.so ${xkb-switch}/lib/libxkbswitch.so
429 '';
430 buildInputs = [ xkb-switch ];
431 });
432
433 vim-yapf = super.vim-yapf.overrideAttrs(old: {
434 buildPhase = ''
435 substituteInPlace ftplugin/python_yapf.vim \
436 --replace '"yapf"' '"${python3.pkgs.yapf}/bin/yapf"'
437 '';
438 });
439
440 vimproc-vim = super.vimproc-vim.overrideAttrs(old: {
441 buildInputs = [ which ];
442
443 buildPhase = ''
444 substituteInPlace autoload/vimproc.vim \
445 --replace vimproc_mac.so vimproc_unix.so \
446 --replace vimproc_linux64.so vimproc_unix.so \
447 --replace vimproc_linux32.so vimproc_unix.so
448 make -f make_unix.mak
449 '';
450 });
451
452 YankRing-vim = super.YankRing-vim.overrideAttrs(old: {
453 sourceRoot = ".";
454 });
455
456 youcompleteme = super.youcompleteme.overrideAttrs(old: {
457 buildPhase = ''
458 substituteInPlace plugin/youcompleteme.vim \
459 --replace "'ycm_path_to_python_interpreter', '''" \
460 "'ycm_path_to_python_interpreter', '${python3}/bin/python3'"
461
462 rm -r third_party/ycmd
463 ln -s ${ycmd}/lib/ycmd third_party
464 '';
465
466 meta = with stdenv.lib; {
467 description = "A code-completion engine for Vim";
468 homepage = "https://github.com/Valloric/YouCompleteMe";
469 license = licenses.gpl3;
470 maintainers = with maintainers; [ marcweber jagajaga ];
471 platforms = platforms.unix;
472 };
473 });
474
475 jedi-vim = super.jedi-vim.overrideAttrs(old: {
476 # checking for python3 support in vim would be neat, too, but nobody else seems to care
477 buildInputs = [ python3.pkgs.jedi ];
478 meta = {
479 description = "code-completion for python using python-jedi";
480 license = stdenv.lib.licenses.mit;
481 };
482 });
483
484 lf-vim = super.lf-vim.overrideAttrs(old: {
485 dependencies = with super; [ bclose-vim ];
486 });
487
488 vim-stylish-haskell = super.vim-stylish-haskell.overrideAttrs (old: {
489 postPatch = old.postPatch or "" + ''
490 substituteInPlace ftplugin/haskell/stylish-haskell.vim --replace \
491 'g:stylish_haskell_command = "stylish-haskell"' \
492 'g:stylish_haskell_command = "${stylish-haskell}/bin/stylish-haskell"'
493 '';
494 });
495
496 vCoolor-vim = super.vCoolor-vim.overrideAttrs(old: {
497 # on linux can use either Zenity or Yad.
498 propagatedBuildInputs = [ gnome3.zenity ];
499 meta = {
500 description = "Simple color selector/picker plugin";
501 license = stdenv.lib.licenses.publicDomain;
502 };
503 });
504
505 unicode-vim = let
506 unicode-data = fetchurl {
507 url = http://www.unicode.org/Public/UNIDATA/UnicodeData.txt;
508 sha256 = "16b0jzvvzarnlxdvs2izd5ia0ipbd87md143dc6lv6xpdqcs75s9";
509 };
510 in super.unicode-vim.overrideAttrs(old: {
511
512 # redirect to /dev/null else changes terminal color
513 buildPhase = ''
514 cp "${unicode-data}" autoload/unicode/UnicodeData.txt
515 echo "Building unicode cache"
516 ${vim}/bin/vim --cmd ":set rtp^=$PWD" -c 'ru plugin/unicode.vim' -c 'UnicodeCache' -c ':echohl Normal' -c ':q' > /dev/null
517 '';
518 });
519}