neovim: generate init.lua by default (#222907)

* wrapNeovimUnstable: generate lua rc files by default

backwards compatible. The viml source is source from init.lua

---------

Co-authored-by: Matthieu Coudron <886074+teto@users.noreply.github.com>

Changed files
+19 -2
pkgs
applications
editors
neovim
+6
pkgs/applications/editors/neovim/tests/default.nix
···
}) (''
source ${nmt}/bash-lib/assertions.sh
vimrc="${writeText "init.vim" neovim-drv.initRc}"
+
luarc="${writeText "init.lua" neovim-drv.luaRcContent}"
+
luarcGeneric="$out/patched.lua"
vimrcGeneric="$out/patched.vim"
mkdir $out
${pkgs.perl}/bin/perl -pe "s|\Q$NIX_STORE\E/[a-z0-9]{32}-|$NIX_STORE/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-|g" < "$vimrc" > "$vimrcGeneric"
+
${pkgs.perl}/bin/perl -pe "s|\Q$NIX_STORE\E/[a-z0-9]{32}-|$NIX_STORE/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-|g" < "$luarc" > "$luarcGeneric"
'' + buildCommand);
in
···
nvim_with_plugins = wrapNeovim2 "-with-plugins" nvimConfNix;
singlelinesconfig = runTest (wrapNeovim2 "-single-lines" nvimConfSingleLines) ''
+
assertFileContains \
+
"$luarcGeneric" \
+
"vim.cmd.source \"/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-init.vim"
assertFileContent \
"$vimrcGeneric" \
"${./init-single-lines.vim}"
+13 -2
pkgs/applications/editors/neovim/wrapper.nix
···
# set to false if you want to control where to save the generated config
# (e.g., in ~/.config/init.vim or project/.nvimrc)
, wrapRc ? true
-
, neovimRcContent ? ""
+
# vimL code that should be sourced as part of the generated init.lua file
+
, neovimRcContent ? null
+
# lua code to put into the generated init.lua file
+
, luaRcContent ? ""
# entry to load in packpath
, packpathDirs
, ...
}:
+
let
+
rcContent = ''
+
${luaRcContent}
+
'' + lib.optionalString (!isNull neovimRcContent) ''
+
vim.cmd.source "${writeText "init.vim" neovimRcContent}"
+
'';
+
wrapperArgsStr = if lib.isString wrapperArgs then wrapperArgs else lib.escapeShellArgs wrapperArgs;
commonWrapperArgs =
···
finalMakeWrapperArgs =
[ "${neovim-unwrapped}/bin/nvim" "${placeholder "out"}/bin/nvim" ]
++ [ "--set" "NVIM_SYSTEM_RPLUGIN_MANIFEST" "${placeholder "out"}/rplugin.vim" ]
-
++ lib.optionals wrapRc [ "--add-flags" "-u ${writeText "init.vim" neovimRcContent}" ]
+
++ lib.optionals wrapRc [ "--add-flags" "-u ${writeText "init.lua" rcContent}" ]
++ commonWrapperArgs
;
···
inherit python3Env rubyEnv;
withRuby = rubyEnv != null;
inherit wrapperArgs;
+
luaRcContent = rcContent;
# Remove the symlinks created by symlinkJoin which we need to perform
# extra actions upon