Loading pkgs/applications/editors/neovim/plugin-submodule.nix +29 −4 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ let plugin = null; config = null; optional = false; type = "viml"; }; in map (x: defaultPlugin // (if x ? plugin then x else { plugin = x; })) plugins; Loading @@ -26,6 +27,15 @@ let example = "set title"; }; type = lib.mkOption { type = lib.types.either (lib.types.enum [ "lua" "viml" ]) lib.types.str; description = "Language used in config. Configurations are aggregated per-language."; default = "viml"; }; optional = mkEnableOption "optional" // { description = "Don't load automatically on startup (load with :packadd)"; }; Loading Loading @@ -78,12 +88,20 @@ in userPluginViml = lib.mkOption { readOnly = true; type = lib.types.listOf lib.types.lines; type = lib.types.nullOr lib.types.lines; description = '' The viml config set by the user. ''; }; userPluginConfigs = lib.mkOption { readOnly = true; type = lib.types.attrsOf lib.types.lines; description = '' The user configurations (viml, lua, ...) set by the user. ''; }; pluginPython3Packages = lib.mkOption { readOnly = true; type = lib.types.listOf (lib.types.functionTo (lib.types.listOf lib.types.package)); Loading @@ -106,6 +124,13 @@ in config = let pluginsNormalized = config.plugins; userPluginConfigs = let grouped = lib.groupBy (x: x.type) pluginsNormalized; configsOnly = lib.foldl (acc: p: if p.config != null then acc ++ [ p.config ] else acc) [ ]; in lib.mapAttrs (_name: vals: lib.concatStringsSep "\n" (configsOnly vals)) grouped; in { pluginAdvisedLua = Loading @@ -125,9 +150,9 @@ in in lib.foldl' op [ ] pluginsNormalized; userPluginViml = lib.foldl ( acc: p: if p.config != null then acc ++ [ p.config ] else acc ) [ ] pluginsNormalized; userPluginViml = userPluginConfigs.viml or null; inherit userPluginConfigs; pluginPython3Packages = map (plugin: plugin.python3Dependencies or (_: [ ])) pluginsNormalized; Loading pkgs/applications/editors/neovim/tests/default.nix +31 −21 Original line number Diff line number Diff line Loading @@ -12,7 +12,6 @@ writeText, neovim, vimPlugins, neovimUtils, wrapNeovimUnstable, neovim-unwrapped, fetchFromGitLab, Loading @@ -21,8 +20,6 @@ pkgs, }: let inherit (neovimUtils) makeNeovimConfig; plugins = with vimPlugins; [ { plugin = vim-obsession; Loading @@ -30,6 +27,14 @@ let map <Leader>$ <Cmd>Obsession<CR> ''; } { plugin = vim-obsession; type = "lua"; config = '' -- this is a comment vim.g.nixpkgs_test_value = 42 ''; } ]; packagesWithSingleLineConfigs = with vimPlugins; [ Loading @@ -43,20 +48,6 @@ let } ]; nvimConfSingleLines = { plugins = packagesWithSingleLineConfigs; neovimRcContent = '' " just a comment ''; }; nvimConfNix = { inherit plugins; neovimRcContent = '' " just a comment ''; }; nvim-with-luasnip = wrapNeovim2 "-with-luasnip" { plugins = [ { Loading Loading @@ -105,6 +96,7 @@ let } ( '' export PATH="${neovim-drv}/bin:$PATH" source ${nmt}/bash-lib/assertions.sh vimrc="${writeText "test-${neovim-drv.name}-init.vim" neovim-drv.initRc}" luarc="${writeText "test-${neovim-drv.name}-init.lua" neovim-drv.luaRcContent}" Loading Loading @@ -139,8 +131,19 @@ pkgs.lib.recurseIntoAttrs rec { ### neovim tests ################## nvim_with_plugins = wrapNeovim2 "-with-plugins" nvimConfNix; nvim_singlelines = wrapNeovim2 "-single-lines" nvimConfSingleLines; nvim_with_plugins = wrapNeovim2 "-with-plugins" { inherit plugins; neovimRcContent = '' " just a comment ''; }; nvim_singlelines = wrapNeovim2 "-single-lines" { plugins = packagesWithSingleLineConfigs; neovimRcContent = '' " just a comment ''; }; # test that passthru.initRc hasn't changed passthruInitRc = runTest nvim_singlelines '' Loading Loading @@ -413,12 +416,19 @@ pkgs.lib.recurseIntoAttrs rec { # 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 '' ${nvim-with-luasnip}/bin/nvim -i NONE -c "lua require'jsregexp'" -e +quitall! nvim --headless -i NONE -c "lua require'jsregexp'" -e +quitall! ''; inherit nvim_with_rocks_nvim; rocks_install_plenary = runTest nvim_with_rocks_nvim '' ${nvim_with_rocks_nvim}/bin/nvim -V3log.txt -i NONE +'Rocks install plenary.nvim' +quit! -e nvim -V3rocks-log.txt -i NONE +'Rocks install plenary.nvim' +quit! -e ''; can_load_lua_config = runTest nvim_with_plugins '' if ! nvim --headless -V3lua-config-log.txt -i NONE -c 'lua if vim.g.nixpkgs_test_value ~= 42 then os.exit(42) end' +quit! -e; then echo "Failed to find plugin config" exit 1 fi ''; inherit (vimPlugins) corePlugins; Loading pkgs/applications/editors/neovim/utils.nix +2 −5 Original line number Diff line number Diff line Loading @@ -6,12 +6,8 @@ config, vimUtils, vimPlugins, nodejs, neovim-unwrapped, bundlerEnv, ruby, lua, python3Packages, wrapNeovimUnstable, }: let Loading Loading @@ -109,11 +105,12 @@ let # viml config set by the user along with the plugin inherit (checked_cfg) userPluginViml userPluginViml # redefine via userPluginConfigs runtimeDeps pluginAdvisedLua pluginPython3Packages luaDependencies userPluginConfigs ; # A Vim "package", see ':h packages' Loading pkgs/applications/editors/neovim/wrapper.nix +7 −2 Original line number Diff line number Diff line Loading @@ -14,7 +14,6 @@ neovimUtils, perl, lndir, vimUtils, runCommand, }: Loading Loading @@ -100,7 +99,10 @@ let # we call vimrcContent without 'packages' to avoid the init.vim generation neovimRcContent' = lib.concatStringsSep "\n" ( vimPackageInfo.userPluginViml ++ lib.optional (neovimRcContent != null) neovimRcContent lib.optional (vimPackageInfo.userPluginConfigs.viml or "" != "") ( vimPackageInfo.userPluginConfigs.viml ) ++ (lib.optional (neovimRcContent != null) neovimRcContent) ); packpathDirs.myNeovimPackages = vimPackageInfo.vimPackage; Loading @@ -126,6 +128,9 @@ let lib.optional (luaDeps != [ ]) luaPathLuaRc ++ [ providerLuaRc ] ++ lib.optional (luaRcContent != "") luaRcContent ++ lib.optional ( vimPackageInfo.userPluginConfigs.lua or "" != "" ) vimPackageInfo.userPluginConfigs.lua ++ lib.optional (neovimRcContent' != "") '' vim.cmd.source "${writeText "init.vim" neovimRcContent'}" '' Loading Loading
pkgs/applications/editors/neovim/plugin-submodule.nix +29 −4 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ let plugin = null; config = null; optional = false; type = "viml"; }; in map (x: defaultPlugin // (if x ? plugin then x else { plugin = x; })) plugins; Loading @@ -26,6 +27,15 @@ let example = "set title"; }; type = lib.mkOption { type = lib.types.either (lib.types.enum [ "lua" "viml" ]) lib.types.str; description = "Language used in config. Configurations are aggregated per-language."; default = "viml"; }; optional = mkEnableOption "optional" // { description = "Don't load automatically on startup (load with :packadd)"; }; Loading Loading @@ -78,12 +88,20 @@ in userPluginViml = lib.mkOption { readOnly = true; type = lib.types.listOf lib.types.lines; type = lib.types.nullOr lib.types.lines; description = '' The viml config set by the user. ''; }; userPluginConfigs = lib.mkOption { readOnly = true; type = lib.types.attrsOf lib.types.lines; description = '' The user configurations (viml, lua, ...) set by the user. ''; }; pluginPython3Packages = lib.mkOption { readOnly = true; type = lib.types.listOf (lib.types.functionTo (lib.types.listOf lib.types.package)); Loading @@ -106,6 +124,13 @@ in config = let pluginsNormalized = config.plugins; userPluginConfigs = let grouped = lib.groupBy (x: x.type) pluginsNormalized; configsOnly = lib.foldl (acc: p: if p.config != null then acc ++ [ p.config ] else acc) [ ]; in lib.mapAttrs (_name: vals: lib.concatStringsSep "\n" (configsOnly vals)) grouped; in { pluginAdvisedLua = Loading @@ -125,9 +150,9 @@ in in lib.foldl' op [ ] pluginsNormalized; userPluginViml = lib.foldl ( acc: p: if p.config != null then acc ++ [ p.config ] else acc ) [ ] pluginsNormalized; userPluginViml = userPluginConfigs.viml or null; inherit userPluginConfigs; pluginPython3Packages = map (plugin: plugin.python3Dependencies or (_: [ ])) pluginsNormalized; Loading
pkgs/applications/editors/neovim/tests/default.nix +31 −21 Original line number Diff line number Diff line Loading @@ -12,7 +12,6 @@ writeText, neovim, vimPlugins, neovimUtils, wrapNeovimUnstable, neovim-unwrapped, fetchFromGitLab, Loading @@ -21,8 +20,6 @@ pkgs, }: let inherit (neovimUtils) makeNeovimConfig; plugins = with vimPlugins; [ { plugin = vim-obsession; Loading @@ -30,6 +27,14 @@ let map <Leader>$ <Cmd>Obsession<CR> ''; } { plugin = vim-obsession; type = "lua"; config = '' -- this is a comment vim.g.nixpkgs_test_value = 42 ''; } ]; packagesWithSingleLineConfigs = with vimPlugins; [ Loading @@ -43,20 +48,6 @@ let } ]; nvimConfSingleLines = { plugins = packagesWithSingleLineConfigs; neovimRcContent = '' " just a comment ''; }; nvimConfNix = { inherit plugins; neovimRcContent = '' " just a comment ''; }; nvim-with-luasnip = wrapNeovim2 "-with-luasnip" { plugins = [ { Loading Loading @@ -105,6 +96,7 @@ let } ( '' export PATH="${neovim-drv}/bin:$PATH" source ${nmt}/bash-lib/assertions.sh vimrc="${writeText "test-${neovim-drv.name}-init.vim" neovim-drv.initRc}" luarc="${writeText "test-${neovim-drv.name}-init.lua" neovim-drv.luaRcContent}" Loading Loading @@ -139,8 +131,19 @@ pkgs.lib.recurseIntoAttrs rec { ### neovim tests ################## nvim_with_plugins = wrapNeovim2 "-with-plugins" nvimConfNix; nvim_singlelines = wrapNeovim2 "-single-lines" nvimConfSingleLines; nvim_with_plugins = wrapNeovim2 "-with-plugins" { inherit plugins; neovimRcContent = '' " just a comment ''; }; nvim_singlelines = wrapNeovim2 "-single-lines" { plugins = packagesWithSingleLineConfigs; neovimRcContent = '' " just a comment ''; }; # test that passthru.initRc hasn't changed passthruInitRc = runTest nvim_singlelines '' Loading Loading @@ -413,12 +416,19 @@ pkgs.lib.recurseIntoAttrs rec { # 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 '' ${nvim-with-luasnip}/bin/nvim -i NONE -c "lua require'jsregexp'" -e +quitall! nvim --headless -i NONE -c "lua require'jsregexp'" -e +quitall! ''; inherit nvim_with_rocks_nvim; rocks_install_plenary = runTest nvim_with_rocks_nvim '' ${nvim_with_rocks_nvim}/bin/nvim -V3log.txt -i NONE +'Rocks install plenary.nvim' +quit! -e nvim -V3rocks-log.txt -i NONE +'Rocks install plenary.nvim' +quit! -e ''; can_load_lua_config = runTest nvim_with_plugins '' if ! nvim --headless -V3lua-config-log.txt -i NONE -c 'lua if vim.g.nixpkgs_test_value ~= 42 then os.exit(42) end' +quit! -e; then echo "Failed to find plugin config" exit 1 fi ''; inherit (vimPlugins) corePlugins; Loading
pkgs/applications/editors/neovim/utils.nix +2 −5 Original line number Diff line number Diff line Loading @@ -6,12 +6,8 @@ config, vimUtils, vimPlugins, nodejs, neovim-unwrapped, bundlerEnv, ruby, lua, python3Packages, wrapNeovimUnstable, }: let Loading Loading @@ -109,11 +105,12 @@ let # viml config set by the user along with the plugin inherit (checked_cfg) userPluginViml userPluginViml # redefine via userPluginConfigs runtimeDeps pluginAdvisedLua pluginPython3Packages luaDependencies userPluginConfigs ; # A Vim "package", see ':h packages' Loading
pkgs/applications/editors/neovim/wrapper.nix +7 −2 Original line number Diff line number Diff line Loading @@ -14,7 +14,6 @@ neovimUtils, perl, lndir, vimUtils, runCommand, }: Loading Loading @@ -100,7 +99,10 @@ let # we call vimrcContent without 'packages' to avoid the init.vim generation neovimRcContent' = lib.concatStringsSep "\n" ( vimPackageInfo.userPluginViml ++ lib.optional (neovimRcContent != null) neovimRcContent lib.optional (vimPackageInfo.userPluginConfigs.viml or "" != "") ( vimPackageInfo.userPluginConfigs.viml ) ++ (lib.optional (neovimRcContent != null) neovimRcContent) ); packpathDirs.myNeovimPackages = vimPackageInfo.vimPackage; Loading @@ -126,6 +128,9 @@ let lib.optional (luaDeps != [ ]) luaPathLuaRc ++ [ providerLuaRc ] ++ lib.optional (luaRcContent != "") luaRcContent ++ lib.optional ( vimPackageInfo.userPluginConfigs.lua or "" != "" ) vimPackageInfo.userPluginConfigs.lua ++ lib.optional (neovimRcContent' != "") '' vim.cmd.source "${writeText "init.vim" neovimRcContent'}" '' Loading