diff options
Diffstat (limited to 'pkgs/applications/editors/neovim')
-rw-r--r-- | pkgs/applications/editors/neovim/neovim-gtk.nix | 40 | ||||
-rw-r--r-- | pkgs/applications/editors/neovim/neovim-remote.nix | 52 | ||||
-rw-r--r-- | pkgs/applications/editors/neovim/tests/default.nix | 20 | ||||
-rw-r--r-- | pkgs/applications/editors/neovim/utils.nix | 54 | ||||
-rw-r--r-- | pkgs/applications/editors/neovim/wrapper.nix | 27 |
5 files changed, 89 insertions, 104 deletions
diff --git a/pkgs/applications/editors/neovim/neovim-gtk.nix b/pkgs/applications/editors/neovim/neovim-gtk.nix deleted file mode 100644 index eebb980f85cb5..0000000000000 --- a/pkgs/applications/editors/neovim/neovim-gtk.nix +++ /dev/null @@ -1,40 +0,0 @@ -{ lib -, rustPlatform -, fetchFromGitHub -, wrapGAppsHook4 -, pkg-config -, gdk-pixbuf -, gtk4 -, pango -, vte-gtk4 -}: - -rustPlatform.buildRustPackage rec { - pname = "neovim-gtk"; - version = "1.0.4"; - - src = fetchFromGitHub { - owner = "Lyude"; - repo = pname; - rev = "v${version}"; - hash = "sha256-inva7pYwOw3bXvFeKZ4aKSQ65iCat5HxM+NME8jN4/I="; - }; - - cargoHash = "sha256-9eZwCOP4xQtFOieqVRBAdXZrXmzdnae6PexGJ/eCyYc="; - - nativeBuildInputs = [ wrapGAppsHook4 pkg-config ]; - - buildInputs = [ gdk-pixbuf gtk4 pango vte-gtk4 ]; - - postInstall = '' - make PREFIX=$out install-resources - ''; - - meta = with lib; { - description = "Gtk ui for neovim"; - homepage = "https://github.com/Lyude/neovim-gtk"; - license = licenses.gpl3Only; - maintainers = with maintainers; [ aleksana ]; - mainProgram = "nvim-gtk"; - }; -} diff --git a/pkgs/applications/editors/neovim/neovim-remote.nix b/pkgs/applications/editors/neovim/neovim-remote.nix deleted file mode 100644 index f85d379faa85c..0000000000000 --- a/pkgs/applications/editors/neovim/neovim-remote.nix +++ /dev/null @@ -1,52 +0,0 @@ -{ lib -, fetchFromGitHub -, python3 -, neovim -, fetchpatch -}: - -with python3.pkgs; buildPythonApplication rec { - pname = "neovim-remote"; - version = "2.5.1"; - - src = fetchFromGitHub { - owner = "mhinz"; - repo = "neovim-remote"; - rev = "v${version}"; - sha256 = "0lbz4w8hgxsw4k1pxafrl3rhydrvi5jc6vnsmkvnhh6l6rxlmvmq"; - }; - - patches = [ - # Fix a compatibility issue with neovim 0.8.0 - (fetchpatch { - url = "https://github.com/mhinz/neovim-remote/commit/56d2a4097f4b639a16902390d9bdd8d1350f948c.patch"; - hash = "sha256-/PjE+9yfHtOUEp3xBaobzRM8Eo2wqOhnF1Es7SIdxvM="; - }) - ]; - - propagatedBuildInputs = [ - pynvim - psutil - setuptools - ]; - - nativeCheckInputs = [ - neovim - pytestCheckHook - ]; - - doCheck = !stdenv.isDarwin; - - preCheck = '' - export HOME="$(mktemp -d)" - ''; - - meta = with lib; { - description = "Tool that helps controlling nvim processes from a terminal"; - homepage = "https://github.com/mhinz/neovim-remote/"; - license = licenses.mit; - maintainers = with maintainers; [ edanaher ]; - platforms = platforms.unix; - mainProgram = "nvr"; - }; -} diff --git a/pkgs/applications/editors/neovim/tests/default.nix b/pkgs/applications/editors/neovim/tests/default.nix index b07f517ea474a..c2e6b565de282 100644 --- a/pkgs/applications/editors/neovim/tests/default.nix +++ b/pkgs/applications/editors/neovim/tests/default.nix @@ -43,6 +43,14 @@ let ''; }; + nvim-with-luasnip = wrapNeovim2 "-with-lua-packages" (makeNeovimConfig { + plugins = [ { + plugin = vimPlugins.luasnip; + + } + ]; + }); + nvimAutoDisableWrap = makeNeovimConfig { }; wrapNeovim2 = suffix: config: @@ -281,4 +289,16 @@ rec { export HOME=$TMPDIR ${nvim_with_opt_plugin}/bin/nvim -i NONE +quit! -e ''; + + inherit nvim-with-luasnip; + + # check that bringing in one plugin with lua deps makes those deps visible from wrapper + # for instance luasnip has a dependency on jsregexp + can_require_transitive_deps = + runTest nvim-with-luasnip '' + export HOME=$TMPDIR + cat ${nvim-with-luasnip}/bin/nvim + ${nvim-with-luasnip}/bin/nvim -i NONE --cmd "lua require'jsregexp'" -e + ''; + }) diff --git a/pkgs/applications/editors/neovim/utils.nix b/pkgs/applications/editors/neovim/utils.nix index 8f9a5b880032c..9f0aa86de48ca 100644 --- a/pkgs/applications/editors/neovim/utils.nix +++ b/pkgs/applications/editors/neovim/utils.nix @@ -7,7 +7,6 @@ , ruby , lua , python3Packages -, writeText , wrapNeovimUnstable , runCommand }: @@ -78,7 +77,7 @@ let ++ (extraPython3Packages ps) ++ (lib.concatMap (f: f ps) pluginPython3Packages)); - luaEnv = neovim-unwrapped.lua.withPackages(extraLuaPackages); + luaEnv = neovim-unwrapped.lua.withPackages extraLuaPackages; # as expected by packdir packpathDirs.myNeovimPackages = myVimPackage; @@ -101,13 +100,13 @@ let "--prefix" "LUA_CPATH" ";" (neovim-unwrapped.lua.pkgs.luaLib.genLuaCPathAbsStr luaEnv) ]; - manifestRc = vimUtils.vimrcContent ({ customRC = ""; }) ; + manifestRc = vimUtils.vimrcContent { customRC = ""; }; # we call vimrcContent without 'packages' to avoid the init.vim generation - neovimRcContent = vimUtils.vimrcContent ({ + neovimRcContent = vimUtils.vimrcContent { beforePlugins = ""; customRC = lib.concatStringsSep "\n" (pluginRC ++ [customRC]); packages = null; - }); + }; in builtins.removeAttrs args ["plugins"] // { @@ -225,16 +224,57 @@ let } // grammar.meta; } '' - mkdir -p $out/parser - ln -s ${grammar}/parser $out/parser/${name}.so + mkdir -p "$out/parser" + ln -s "${grammar}/parser" "$out/parser/${name}.so" + + mkdir -p "$out/queries/${name}" + if [ -d "${grammar}/queries/${name}" ]; then + echo "moving queries from neovim queries dir" + for file in "${grammar}/queries/${name}"*; do + ln -s "$file" "$out/queries/${name}/$(basename "$file")" + done + else + if [ -d "${grammar}/queries" ]; then + echo "moving queries from standard queries dir" + for file in "${grammar}/queries/"*; do + ln -s "$file" "$out/queries/${name}/$(basename "$file")" + done + else + echo "missing queries for ${name}" + fi + fi ''); + /* + Fork of vimUtils.packDir that additionnally generates a propagated-build-inputs-file that + can be used by the lua hooks to generate a proper LUA_PATH + + Generates a packpath folder as expected by vim + Example: + packDir ( {myVimPackage = { start = [ vimPlugins.vim-fugitive ]; opt = []; }; }) + => "/nix/store/xxxxx-pack-dir" + */ + packDir = packages: + let + rawPackDir = vimUtils.packDir packages; + + in + rawPackDir.override ({ + postBuild = '' + mkdir $out/nix-support + for i in $(find -L $out -name propagated-build-inputs ); do + cat "$i" >> $out/nix-support/propagated-build-inputs + done + '';}); + + in { inherit makeNeovimConfig; inherit generateProviderRc; inherit legacyWrapper; inherit grammarToPlugin; + inherit packDir; inherit buildNeovimPlugin; buildNeovimPluginFrom2Nix = lib.warn "buildNeovimPluginFrom2Nix was renamed to buildNeovimPlugin" buildNeovimPlugin; diff --git a/pkgs/applications/editors/neovim/wrapper.nix b/pkgs/applications/editors/neovim/wrapper.nix index e877f1e1f764a..d86de46c87385 100644 --- a/pkgs/applications/editors/neovim/wrapper.nix +++ b/pkgs/applications/editors/neovim/wrapper.nix @@ -13,6 +13,9 @@ neovim-unwrapped: let + # inherit interpreter from neovim + lua = neovim-unwrapped.lua; + wrapper = { extraName ? "" # should contain all args but the binary. Can be either a string or list @@ -24,6 +27,8 @@ let , withNodeJs ? false , withPerl ? false , rubyEnv ? null + + # wether to create symlinks in $out/bin/vi(m) -> $out/bin/nvim , vimAlias ? false , viAlias ? false @@ -45,6 +50,8 @@ let stdenv.mkDerivation (finalAttrs: let + finalPackdir = neovimUtils.packDir packpathDirs; + rcContent = '' ${luaRcContent} '' + lib.optionalString (!isNull neovimRcContent) '' @@ -57,10 +64,10 @@ let # vim accepts a limited number of commands so we join them all [ "--add-flags" ''--cmd "lua ${providerLuaRc}"'' - # (lib.intersperse "|" hostProviderViml) - ] ++ lib.optionals (packpathDirs.myNeovimPackages.start != [] || packpathDirs.myNeovimPackages.opt != []) [ - "--add-flags" ''--cmd "set packpath^=${vimUtils.packDir packpathDirs}"'' - "--add-flags" ''--cmd "set rtp^=${vimUtils.packDir packpathDirs}"'' + ] + ++ lib.optionals (packpathDirs.myNeovimPackages.start != [] || packpathDirs.myNeovimPackages.opt != []) [ + "--add-flags" ''--cmd "set packpath^=${finalPackdir}"'' + "--add-flags" ''--cmd "set rtp^=${finalPackdir}"'' ] ; @@ -160,7 +167,17 @@ let + '' rm $out/bin/nvim touch $out/rplugin.vim - makeWrapper ${lib.escapeShellArgs finalMakeWrapperArgs} ${wrapperArgsStr} + + echo "Looking for lua dependencies..." + source ${lua}/nix-support/utils.sh + + _addToLuaPath "${finalPackdir}" + + echo "LUA_PATH towards the end of packdir: $LUA_PATH" + + makeWrapper ${lib.escapeShellArgs finalMakeWrapperArgs} ${wrapperArgsStr} \ + --prefix LUA_PATH ';' "$LUA_PATH" \ + --prefix LUA_CPATH ';' "$LUA_CPATH" ''; buildPhase = '' |