diff options
author | Lucas Hoffmann <lucc@users.noreply.github.com> | 2023-12-27 20:38:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-27 20:38:59 +0100 |
commit | 1ada32da4ba24d7310653c9ac54888bee463f455 (patch) | |
tree | 8617705c8d783c000947b9e588e01c87acc6f034 /pkgs/applications/editors/neovim | |
parent | 628b90b5ad0a526dba2daeb17d07ce248f0c5275 (diff) | |
download | nixlib-1ada32da4ba24d7310653c9ac54888bee463f455.tar nixlib-1ada32da4ba24d7310653c9ac54888bee463f455.tar.gz nixlib-1ada32da4ba24d7310653c9ac54888bee463f455.tar.bz2 nixlib-1ada32da4ba24d7310653c9ac54888bee463f455.tar.lz nixlib-1ada32da4ba24d7310653c9ac54888bee463f455.tar.xz nixlib-1ada32da4ba24d7310653c9ac54888bee463f455.tar.zst nixlib-1ada32da4ba24d7310653c9ac54888bee463f455.zip |
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>
Diffstat (limited to 'pkgs/applications/editors/neovim')
-rw-r--r-- | pkgs/applications/editors/neovim/tests/default.nix | 6 | ||||
-rw-r--r-- | pkgs/applications/editors/neovim/wrapper.nix | 15 |
2 files changed, 19 insertions, 2 deletions
diff --git a/pkgs/applications/editors/neovim/tests/default.nix b/pkgs/applications/editors/neovim/tests/default.nix index a7e0e4c77057..cbe811c33b68 100644 --- a/pkgs/applications/editors/neovim/tests/default.nix +++ b/pkgs/applications/editors/neovim/tests/default.nix @@ -74,9 +74,12 @@ let }) ('' 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 @@ -89,6 +92,9 @@ rec { 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}" diff --git a/pkgs/applications/editors/neovim/wrapper.nix b/pkgs/applications/editors/neovim/wrapper.nix index d61a2fe5e5a8..48c9c94e8e07 100644 --- a/pkgs/applications/editors/neovim/wrapper.nix +++ b/pkgs/applications/editors/neovim/wrapper.nix @@ -32,13 +32,23 @@ let # 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 = @@ -66,7 +76,7 @@ let 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 ; @@ -84,6 +94,7 @@ let inherit python3Env rubyEnv; withRuby = rubyEnv != null; inherit wrapperArgs; + luaRcContent = rcContent; # Remove the symlinks created by symlinkJoin which we need to perform # extra actions upon |