diff options
author | Jörg Thalheim <Mic92@users.noreply.github.com> | 2019-01-21 20:45:06 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-21 20:45:06 +0000 |
commit | fa8f1340ffbc65b2a79aa412948c6d996a460d7a (patch) | |
tree | dae95f1725f81f776da39e42d90a5599b8de7f30 /pkgs/applications | |
parent | 68553b756fa2caafbb878002b8f0f6b17d4cf486 (diff) | |
parent | 2bc0e00372b60eeb80797f193f6a963ce10a0516 (diff) |
Merge pull request #53084 from timokau/neovim-remote-plugins
neovim: generate remote plugin manifest
Diffstat (limited to 'pkgs/applications')
-rw-r--r-- | pkgs/applications/editors/neovim/default.nix | 7 | ||||
-rw-r--r-- | pkgs/applications/editors/neovim/system_rplugin_manifest.patch | 29 | ||||
-rw-r--r-- | pkgs/applications/editors/neovim/wrapper.nix | 44 |
3 files changed, 68 insertions, 12 deletions
diff --git a/pkgs/applications/editors/neovim/default.nix b/pkgs/applications/editors/neovim/default.nix index a3580b1afa7a6..27e274326470c 100644 --- a/pkgs/applications/editors/neovim/default.nix +++ b/pkgs/applications/editors/neovim/default.nix @@ -20,6 +20,13 @@ let sha256 = "07ncvgp6xfhiwc6hd7qf7zk28n3yj47p26qj1ji29vqkwnk28y3s"; }; + patches = [ + # introduce a system-wide rplugin.vim in addition to the user one + # necessary so that nix can handle `UpdateRemotePlugins` for the plugins + # it installs. See https://github.com/neovim/neovim/issues/9413. + ./system_rplugin_manifest.patch + ]; + enableParallelBuilding = true; buildInputs = [ diff --git a/pkgs/applications/editors/neovim/system_rplugin_manifest.patch b/pkgs/applications/editors/neovim/system_rplugin_manifest.patch new file mode 100644 index 0000000000000..f634d3ec056a2 --- /dev/null +++ b/pkgs/applications/editors/neovim/system_rplugin_manifest.patch @@ -0,0 +1,29 @@ +diff --git a/runtime/autoload/remote/host.vim b/runtime/autoload/remote/host.vim +index 6266b312b..965fabf1e 100644 +--- a/runtime/autoload/remote/host.vim ++++ b/runtime/autoload/remote/host.vim +@@ -71,7 +71,8 @@ function! remote#host#RegisterPlugin(host, path, specs) abort + + for plugin in plugins + if plugin.path == a:path +- throw 'Plugin "'.a:path.'" is already registered' ++ " plugin already registered ++ return + endif + endfor + +diff --git a/runtime/plugin/rplugin.vim b/runtime/plugin/rplugin.vim +index 122d8d47f..83fbf8b57 100644 +--- a/runtime/plugin/rplugin.vim ++++ b/runtime/plugin/rplugin.vim +@@ -54,6 +54,10 @@ function! s:GetManifest() abort + endfunction + + function! s:LoadRemotePlugins() abort ++ if exists('$NVIM_SYSTEM_RPLUGIN_MANIFEST') ++ let g:system_remote_plugins = fnamemodify($NVIM_SYSTEM_RPLUGIN_MANIFEST, ':p') ++ execute 'source' fnameescape(g:system_remote_plugins) ++ endif + let g:loaded_remote_plugins = s:GetManifest() + if filereadable(g:loaded_remote_plugins) + execute 'source' fnameescape(g:loaded_remote_plugins) diff --git a/pkgs/applications/editors/neovim/wrapper.nix b/pkgs/applications/editors/neovim/wrapper.nix index 3dd3710da772e..7d76bc1fd1a0c 100644 --- a/pkgs/applications/editors/neovim/wrapper.nix +++ b/pkgs/applications/editors/neovim/wrapper.nix @@ -72,7 +72,6 @@ let --cmd \"${if withRuby then "let g:ruby_host_prog='$out/bin/nvim-ruby'" else "let g:loaded_ruby_provider=1"}\" " \ --suffix PATH : ${binPath} \ ${optionalString withRuby '' --set GEM_HOME ${rubyEnv}/${rubyEnv.ruby.gemPath}'' } - '' + optionalString (!stdenv.isDarwin) '' # copy and patch the original neovim.desktop file @@ -83,18 +82,39 @@ let '' + optionalString withPython '' makeWrapper ${pythonEnv}/bin/python $out/bin/nvim-python --unset PYTHONPATH - '' + optionalString withPython3 '' + '' + optionalString withPython3 '' makeWrapper ${python3Env}/bin/python3 $out/bin/nvim-python3 --unset PYTHONPATH - '' + optionalString withRuby '' - ln -s ${rubyEnv}/bin/neovim-ruby-host $out/bin/nvim-ruby - '' + optionalString vimAlias '' - ln -s $out/bin/nvim $out/bin/vim - '' + optionalString viAlias '' - ln -s $out/bin/nvim $out/bin/vi - '' + optionalString (configure != {}) '' - wrapProgram $out/bin/nvim --add-flags "-u ${vimUtils.vimrcFile configure}" - '' - ; + '' + optionalString withRuby '' + ln -s ${rubyEnv}/bin/neovim-ruby-host $out/bin/nvim-ruby + '' + optionalString vimAlias '' + ln -s $out/bin/nvim $out/bin/vim + '' + optionalString viAlias '' + ln -s $out/bin/nvim $out/bin/vi + '' + optionalString (configure != {}) '' + echo "Generating remote plugin manifest" + export NVIM_RPLUGIN_MANIFEST=$out/rplugin.vim + # Launch neovim with a vimrc file containing only the generated plugin + # code. Pass various flags to disable temp file generation + # (swap/viminfo) and redirect errors to stderr. + # Only display the log on error since it will contain a few normally + # irrelevant messages. + if ! $out/bin/nvim \ + -u ${vimUtils.vimrcFile (configure // { customRC = ""; })} \ + -i NONE -n \ + -E -V1rplugins.log -s \ + +UpdateRemotePlugins +quit! > outfile 2>&1; then + cat outfile + echo -e "\nGenerating rplugin.vim failed!" + exit 1 + fi + unset NVIM_RPLUGIN_MANIFEST + + # this relies on a patched neovim, see + # https://github.com/neovim/neovim/issues/9413 + wrapProgram $out/bin/nvim \ + --set NVIM_SYSTEM_RPLUGIN_MANIFEST $out/rplugin.vim \ + --add-flags "-u ${vimUtils.vimrcFile configure}" + ''; preferLocalBuild = true; |