neovim: correctly concat single line configs
The changes introduced in https://github.com/NixOS/nixpkgs/pull/184364#discussion_r945772144 didn't concat correctly the plugin configs when they were a single string see: https://github.com/nix-community/home-manager/pull/3147 This adds a test for it.
This commit is contained in:
committed by
Matthieu Coudron
parent
96905cef35
commit
e3c0484acd
+28
-2
@@ -2,6 +2,7 @@
|
||||
, lib, fetchFromGitHub, neovimUtils, wrapNeovimUnstable
|
||||
, neovim-unwrapped
|
||||
, fetchFromGitLab
|
||||
, runCommandLocal
|
||||
, pkgs
|
||||
}:
|
||||
let
|
||||
@@ -19,6 +20,24 @@ let
|
||||
}
|
||||
];
|
||||
|
||||
packagesWithSingleLineConfigs = with vimPlugins; [
|
||||
{
|
||||
plugin = vim-obsession;
|
||||
config = ''map <Leader>$ <Cmd>Obsession<CR>'';
|
||||
}
|
||||
{
|
||||
plugin = trouble-nvim;
|
||||
config = ''" placeholder config'';
|
||||
}
|
||||
];
|
||||
|
||||
nvimConfSingleLines = makeNeovimConfig {
|
||||
plugins = packagesWithSingleLineConfigs;
|
||||
customRC = ''
|
||||
" just a comment
|
||||
'';
|
||||
};
|
||||
|
||||
nvimConfNix = makeNeovimConfig {
|
||||
inherit plugins;
|
||||
customRC = ''
|
||||
@@ -47,8 +66,9 @@ let
|
||||
sha256 = "1ykcvyx82nhdq167kbnpgwkgjib8ii7c92y3427v986n2s5lsskc";
|
||||
};
|
||||
|
||||
# neovim-drv must be a wrapped neovim
|
||||
runTest = neovim-drv: buildCommand:
|
||||
pkgs.runCommandLocal "test-${neovim-drv.name}" ({
|
||||
runCommandLocal "test-${neovim-drv.name}" ({
|
||||
nativeBuildInputs = [ ];
|
||||
meta.platforms = neovim-drv.meta.platforms;
|
||||
}) (''
|
||||
@@ -68,6 +88,12 @@ rec {
|
||||
##################
|
||||
nvim_with_plugins = wrapNeovim2 "-with-plugins" nvimConfNix;
|
||||
|
||||
singlelinesconfig = runTest (wrapNeovim2 "-single-lines" nvimConfSingleLines) ''
|
||||
assertFileContent \
|
||||
"$vimrcGeneric" \
|
||||
"${./init-single-lines.vim}"
|
||||
'';
|
||||
|
||||
nvim_via_override = neovim.override {
|
||||
extraName = "-via-override";
|
||||
configure = {
|
||||
@@ -131,7 +157,7 @@ rec {
|
||||
nvim_via_override-test = runTest nvim_via_override ''
|
||||
assertFileContent \
|
||||
"$vimrcGeneric" \
|
||||
"${./neovim-override.vim}"
|
||||
"${./init-override.vim}"
|
||||
'';
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
map <Leader>$ <Cmd>Obsession<CR>
|
||||
" placeholder config
|
||||
" just a comment
|
||||
@@ -49,12 +49,17 @@ let
|
||||
};
|
||||
|
||||
# transform all plugins into an attrset
|
||||
# { optional = bool; plugin = package; dest = filename; }
|
||||
pluginsNormalized = map (x: if x ? plugin then { dest = "init.vim"; optional = false; } // x else { plugin = x; optional = false;}) plugins;
|
||||
# { optional = bool; plugin = package; }
|
||||
pluginsNormalized = let
|
||||
defaultPlugin = {
|
||||
plugin = null;
|
||||
config = null;
|
||||
optional = false;
|
||||
};
|
||||
in
|
||||
map (x: defaultPlugin // (if (x ? plugin) then x else { plugin = x; })) plugins;
|
||||
|
||||
|
||||
|
||||
pluginRC = lib.concatMapStrings (p: p.config or "") pluginsNormalized;
|
||||
pluginRC = lib.foldl (acc: p: if p.config != null then acc ++ [p.config] else acc) [] pluginsNormalized;
|
||||
|
||||
pluginsPartitioned = lib.partition (x: x.optional == true) pluginsNormalized;
|
||||
requiredPlugins = vimUtils.requiredPluginsForPackage myVimPackage;
|
||||
@@ -116,7 +121,11 @@ let
|
||||
|
||||
manifestRc = vimUtils.vimrcContent ({ customRC = ""; }) ;
|
||||
# we call vimrcContent without 'packages' to avoid the init.vim generation
|
||||
neovimRcContent = vimUtils.vimrcContent ({ beforePlugins = ""; customRC = pluginRC + customRC; packages = null; });
|
||||
neovimRcContent = vimUtils.vimrcContent ({
|
||||
beforePlugins = "";
|
||||
customRC = lib.concatStringsSep "\n" (pluginRC ++ [customRC]);
|
||||
packages = null;
|
||||
});
|
||||
in
|
||||
|
||||
builtins.removeAttrs args ["plugins"] // {
|
||||
|
||||
@@ -123,7 +123,7 @@ let
|
||||
unwrapped = neovim;
|
||||
initRc = neovimRcContent;
|
||||
|
||||
tests = callPackage ./tests.nix {
|
||||
tests = callPackage ./tests {
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user