mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
modules/performance: add ability to byte compile nvim runtime directory
This commit adds `performance.byteCompileLua.nvimRuntime` toggle that, if enabled, byte compiles all lua files in Nvim runtime directory.
This commit is contained in:
parent
55ca9d235b
commit
9314cd46f0
3 changed files with 59 additions and 1 deletions
|
@ -21,6 +21,9 @@ in
|
|||
plugins = lib.mkEnableOption "plugins" // {
|
||||
description = "Whether to byte compile lua plugins.";
|
||||
};
|
||||
nvimRuntime = lib.mkEnableOption "nvimRuntime" // {
|
||||
description = "Whether to byte compile lua files in Nvim runtime.";
|
||||
};
|
||||
};
|
||||
|
||||
combinePlugins = {
|
||||
|
|
|
@ -244,7 +244,28 @@ in
|
|||
++ (optional config.wrapRc ''--add-flags -u --add-flags "${init}"'')
|
||||
);
|
||||
|
||||
wrappedNeovim = pkgs.wrapNeovimUnstable config.package (
|
||||
package =
|
||||
if config.performance.byteCompileLua.enable && config.performance.byteCompileLua.nvimRuntime then
|
||||
# Using symlinkJoin to avoid rebuilding neovim
|
||||
pkgs.symlinkJoin {
|
||||
name = "neovim-byte-compiled-${lib.getVersion config.package}";
|
||||
paths = [ config.package ];
|
||||
# Required attributes from original neovim package
|
||||
inherit (config.package) lua;
|
||||
nativeBuildInputs = [ helpers.byteCompileLuaHook ];
|
||||
postBuild = ''
|
||||
# Replace Nvim's binary symlink with a regular file,
|
||||
# or Nvim will use original runtime directory
|
||||
rm $out/bin/nvim
|
||||
cp ${config.package}/bin/nvim $out/bin/nvim
|
||||
|
||||
runHook postFixup
|
||||
'';
|
||||
}
|
||||
else
|
||||
config.package;
|
||||
|
||||
wrappedNeovim = pkgs.wrapNeovimUnstable package (
|
||||
neovimConfig
|
||||
// {
|
||||
wrapperArgs = lib.escapeShellArgs neovimConfig.wrapperArgs + " " + extraWrapperArgs;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue