mirror of
https://github.com/nix-community/home-manager
synced 2024-11-27 05:29:46 +01:00
neovim: Source neovimRcContent directly from store (#3444)
The previous version linked the file into home, then sourced that. Since nothing else expects that file to be there, this is unnecessary. Additionally, doing so made it impossible to test a built config without switching, e.g. using `XDG_CONFIG_HOME=… nvim` or `nvim -u`. This remedies that, at least for this particular reference. To test this, change from asserting contents of the config file to actually starting nvim, outputting sentinel values, and then asserting their values are present. This way it’s tested that nvim loaded the config, rather than that some config is in a specific place. This is all in one commit as the test, as written now, would not have worked before since the previously hard-coded home path was not an actual file in the test environment.
This commit is contained in:
parent
e38ce0ae16
commit
478610aa37
3 changed files with 12 additions and 20 deletions
|
@ -365,15 +365,13 @@ in {
|
||||||
in mkMerge (
|
in mkMerge (
|
||||||
# writes runtime
|
# writes runtime
|
||||||
(map (x: x.runtime) pluginsNormalized) ++ [{
|
(map (x: x.runtime) pluginsNormalized) ++ [{
|
||||||
"nvim/init-home-manager.vim" =
|
|
||||||
mkIf (neovimConfig.neovimRcContent != "") {
|
|
||||||
text = neovimConfig.neovimRcContent;
|
|
||||||
};
|
|
||||||
"nvim/init.lua" = let
|
"nvim/init.lua" = let
|
||||||
luaRcContent =
|
luaRcContent =
|
||||||
lib.optionalString (neovimConfig.neovimRcContent != "")
|
lib.optionalString (neovimConfig.neovimRcContent != "")
|
||||||
"vim.cmd [[source ${config.xdg.configHome}/nvim/init-home-manager.vim]]"
|
"vim.cmd [[source ${
|
||||||
+ lib.optionalString hasLuaConfig
|
pkgs.writeText "nvim-init-home-manager.vim"
|
||||||
|
neovimConfig.neovimRcContent
|
||||||
|
}]]" + lib.optionalString hasLuaConfig
|
||||||
config.programs.neovim.generatedConfigs.lua;
|
config.programs.neovim.generatedConfigs.lua;
|
||||||
in mkIf (luaRcContent != "") { text = luaRcContent; };
|
in mkIf (luaRcContent != "") { text = luaRcContent; };
|
||||||
|
|
||||||
|
|
|
@ -7,16 +7,14 @@ with lib;
|
||||||
programs.neovim = {
|
programs.neovim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
" This 'extraConfig' should be present in vimrc
|
let g:hmExtraConfig='HM_EXTRA_CONFIG'
|
||||||
'';
|
'';
|
||||||
plugins = with pkgs.vimPlugins; [
|
plugins = with pkgs.vimPlugins; [
|
||||||
vim-nix
|
vim-nix
|
||||||
{
|
{
|
||||||
plugin = vim-commentary;
|
plugin = vim-commentary;
|
||||||
config = ''
|
config = ''
|
||||||
" plugin-specific config
|
let g:hmPlugins='HM_PLUGINS_CONFIG'
|
||||||
autocmd FileType c setlocal commentstring=//\ %s
|
|
||||||
autocmd FileType c setlocal comments=://
|
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -24,11 +22,12 @@ with lib;
|
||||||
};
|
};
|
||||||
|
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
vimrc="$TESTED/home-files/.config/nvim/init-home-manager.vim"
|
vimout=$(mktemp)
|
||||||
vimrcNormalized="$(normalizeStorePaths "$vimrc")"
|
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" \
|
||||||
assertFileExists "$vimrc"
|
> "$vimout"
|
||||||
assertFileContent "$vimrcNormalized" "${./plugin-config.vim}"
|
assertFileContains "$vimout" "HM_EXTRA_CONFIG"
|
||||||
|
assertFileContains "$vimout" "HM_PLUGINS_CONFIG"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
" plugin-specific config
|
|
||||||
autocmd FileType c setlocal commentstring=//\ %s
|
|
||||||
autocmd FileType c setlocal comments=://
|
|
||||||
|
|
||||||
" This 'extraConfig' should be present in vimrc
|
|
Loading…
Reference in a new issue