1
0
Fork 0
mirror of https://github.com/nix-community/nixvim.git synced 2025-11-08 19:46:06 +01:00

modules/performance: add excludedPlugins option to byte compilation

Signed-off-by: saygo-png <saygo.mail@proton.me>
This commit is contained in:
saygo-png 2025-09-08 00:24:20 +02:00 committed by Matt Sturgeon
parent 43c6f7293e
commit cd427977f3
3 changed files with 27 additions and 3 deletions

View file

@ -60,6 +60,17 @@ in
luaLib = lib.mkEnableOption "luaLib" // { luaLib = lib.mkEnableOption "luaLib" // {
description = "Whether to byte compile lua library."; description = "Whether to byte compile lua library.";
}; };
excludedPlugins = lib.mkOption {
type = with types; listOf (either str package);
default = [ ];
example = lib.literalExpression ''
[
"faster.nvim"
pkgs.vimPlugins.conform-nvim
];
'';
description = "List of plugins (names or packages) to exclude from byte compilation.";
};
}; };
combinePlugins = { combinePlugins = {

View file

@ -4,15 +4,25 @@
Inputs: List of normalized plugins Inputs: List of normalized plugins
Outputs: List of normalized (compiled) plugins Outputs: List of normalized (compiled) plugins
*/ */
{ lib, pkgs }: {
lib,
pkgs,
excludedPlugins,
}:
normalizedPlugins:
let let
builders = lib.nixvim.builders.withPkgs pkgs; builders = lib.nixvim.builders.withPkgs pkgs;
inherit (import ./utils.nix lib) mapNormalizedPlugins; inherit (import ./utils.nix lib) mapNormalizedPlugins;
excludedNames = map (p: if builtins.isString p then p else lib.getName p) excludedPlugins;
isExcluded = p: builtins.elem (lib.getName p.plugin) excludedNames;
partitionedPlugins = builtins.partition isExcluded normalizedPlugins;
byteCompile = byteCompile =
p: p:
(builders.byteCompileLuaDrv p).overrideAttrs ( (builders.byteCompileLuaDrv p).overrideAttrs (
prev: lib.optionalAttrs (prev ? dependencies) { dependencies = map byteCompile prev.dependencies; } prev: lib.optionalAttrs (prev ? dependencies) { dependencies = map byteCompile prev.dependencies; }
); );
in in
mapNormalizedPlugins byteCompile (mapNormalizedPlugins byteCompile partitionedPlugins.wrong) ++ partitionedPlugins.right

View file

@ -32,7 +32,10 @@ in
build.plugins = build.plugins =
let let
shouldCompilePlugins = byteCompileCfg.enable && byteCompileCfg.plugins; shouldCompilePlugins = byteCompileCfg.enable && byteCompileCfg.plugins;
byteCompilePlugins = pkgs.callPackage ./byte-compile-plugins.nix { inherit lib; }; byteCompilePlugins = pkgs.callPackage ./byte-compile-plugins.nix {
inherit lib;
inherit (config.performance.byteCompileLua) excludedPlugins;
};
shouldCompileLuaLib = byteCompileCfg.enable && byteCompileCfg.luaLib; shouldCompileLuaLib = byteCompileCfg.enable && byteCompileCfg.luaLib;
inherit (pkgs.callPackage ./byte-compile-lua-lib.nix { inherit lib; }) byteCompilePluginDeps; inherit (pkgs.callPackage ./byte-compile-lua-lib.nix { inherit lib; }) byteCompilePluginDeps;