1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-21 17:59:39 +01:00
home-manager/tests/modules/programs/neovim/plugin-config.nix
Evgeny Zislis 1df816c407
fix: ensure newline after vim.cmd[[source...]] in neovim init.lua (#7219)
Fix an issue where the generated ~/.config/nvim/init.lua lacks a newline after the vim.cmd [[source ...]] directive. Without this newline, subsequent lua configuration is concatenated onto the same line, breaking lua syntax.

init.lua Before:

vim.cmd [[source /nix/store/...]]vim.opt.rtp:prepend(...)

After:

vim.cmd [[source /nix/store/...]]
vim.opt.rtp:prepend(...)
2025-06-09 22:10:54 +02:00

48 lines
1.1 KiB
Nix

{
config,
lib,
pkgs,
realPkgs,
...
}:
lib.mkIf config.test.enableBig {
programs.neovim = {
enable = true;
extraConfig = ''
let g:hmExtraConfig='HM_EXTRA_CONFIG'
'';
plugins = with pkgs.vimPlugins; [
vim-nix
{
plugin = vim-commentary;
config = ''
let g:hmPlugins='HM_PLUGINS_CONFIG'
'';
}
{
plugin = vim-nix;
type = "lua";
config = ''
function HM_PLUGIN_LUA_CONFIG ()
end
'';
}
];
extraLuaPackages = ps: [ ps.luautf8 ];
};
_module.args.pkgs = lib.mkForce realPkgs;
nmt.script = ''
vimout=$(mktemp)
echo "redir >> /dev/stdout | echo g:hmExtraConfig | echo g:hmPlugins | redir END" \
| ${pkgs.neovim}/bin/nvim -es -u "$TESTED/home-files/.config/nvim/init.lua" \
> "$vimout" || true
assertFileContains "$vimout" "HM_EXTRA_CONFIG"
assertFileContains "$vimout" "HM_PLUGINS_CONFIG"
initLua="$TESTED/home-files/.config/nvim/init.lua"
assertFileContent "$initLua" ${./plugin-config.expected}
'';
}