From 1ada32da4ba24d7310653c9ac54888bee463f455 Mon Sep 17 00:00:00 2001 From: Lucas Hoffmann Date: Wed, 27 Dec 2023 20:38:59 +0100 Subject: 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> --- pkgs/applications/editors/neovim/wrapper.nix | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'pkgs/applications/editors/neovim/wrapper.nix') diff --git a/pkgs/applications/editors/neovim/wrapper.nix b/pkgs/applications/editors/neovim/wrapper.nix index d61a2fe5e5a81..48c9c94e8e075 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 -- cgit 1.4.1