Pack every start plugins together

This commit is contained in:
2024-12-24 19:08:38 +01:00
parent 848e9b83c6
commit 52124f0f02
5 changed files with 114 additions and 30 deletions
+5 -6
View File
@@ -58,13 +58,12 @@
}
);
byteCompile = plugins: let
byteCompile = p:
(byteCompileLuaDrv p).overrideAttrs (
prev: lib.optionalAttrs (prev ? dependencies) {dependencies = map byteCompile prev.dependencies;}
);
byteCompile = p: let
drv = (byteCompileLuaDrv p.plugin).overrideAttrs (
prev: lib.optionalAttrs (prev ? dependencies) {dependencies = map byteCompile prev.dependencies;}
);
in
map (p: p // {plugin = byteCompile p.plugin;}) plugins;
p // {plugin = drv;};
byteCompileVim = package:
pkgs.symlinkJoin {
+9 -10
View File
@@ -14,16 +14,15 @@ in
config = ./.;
plugins = with pkgs.vimPlugins; [
{
plugin = lz-n;
optional = false;
}
# TODO: make grammars optional
# nvim-treesitter.withAllGrammars
catppuccin-nvim
];
plugins = with pkgs.vimPlugins; {
start = [
lz-n
catppuccin-nvim
nvim-treesitter.withAllGrammars
];
opts = [
];
};
extraPackages = with pkgs; [
# lsp
+1
View File
@@ -2,6 +2,7 @@ return {
{
"catppuccin-nvim",
-- colorscheme = "catppuccin",
load = function()end,
priority = 1000,
opt = {
integrations = {
+19 -14
View File
@@ -5,7 +5,10 @@
}: {
package ? pkgs.neovim,
config,
plugins ? [],
plugins ? {
start = [];
opts = [];
},
extraPackages ? [],
extraLuaPackages ? p: [],
extraPython3Packages ? p: [],
@@ -15,22 +18,19 @@
withNodeJs ? false,
withSqlite ? false,
}: let
# Stolen from pkgs.neovimUtils.normalizePlugins but this changes defaultPlugin.optional to true.
normalizePlugins = plugins: let
normalize = optional: p: let
defaultPlugin = {
plugin = null;
config = null;
optional = true;
inherit optional;
};
in
map (x:
defaultPlugin
// (
if (x ? plugin)
then x
else {plugin = x;}
))
plugins;
defaultPlugin
// (
if (p ? plugin)
then p
else {plugin = p;}
);
initLua =
# lua
@@ -38,17 +38,22 @@
vim.opt.rtp:remove(vim.fn.stdpath('config')) -- ~/.config/nvim
vim.opt.rtp:remove(vim.fn.stdpath('config') .. "/after") -- ~/.config/nvim/after
vim.opt.rtp:prepend('${config}')
vim.opt.rtp:prepend('${config}/after')
vim.opt.rtp:append('${config}/after')
${builtins.readFile (config + "/init.lua")}
'';
builder = (import ./bytecompile.nix) {inherit pkgs lib;};
pack = (import ./pack.nix) {inherit pkgs lib;};
nvim = builder.byteCompileVim package;
start = map (p: lib.pipe p [(normalize false) builder.byteCompile]) plugins.start;
opts = map (p: lib.pipe p [(normalize true) builder.byteCompile]) plugins.opts;
startPacked = pack.packPlugins start;
in
pkgs.wrapNeovimUnstable nvim {
plugins = builder.byteCompile (normalizePlugins plugins);
plugins = [startPacked] ++ opts;
wrapRc = false;
wrapperArgs = builtins.concatStringsSep " " [
+80
View File
@@ -0,0 +1,80 @@
{
pkgs,
lib,
...
}: {
packPlugins = plugins: let
# Set option value with default priority so that values are appended by default
pathsToLink = [
# :h rtp
"/autoload"
"/colors"
"/compiler"
"/doc"
"/ftplugin"
"/indent"
"/keymap"
"/lang"
"/lua"
"/pack"
"/parser"
"/plugin"
"/queries"
"/rplugin"
"/spell"
"/syntax"
"/tutor"
"/after"
"/ftdetect"
# plenary.nvim
"/data/plenary/filetypes"
];
# Every plugin has its own generated help tags (doc/tags)
# Remove them to avoid collisions, new help tags
# will be generate for the entire pack later on
overriddenPlugins =
map (
plugin:
plugin.plugin.overrideAttrs (prev: {
nativeBuildInputs = lib.remove pkgs.vimUtils.vimGenDocHook prev.nativeBuildInputs or [];
configurePhase = ''
${prev.configurePhase or ""}
rm -vf doc/tags'';
})
)
plugins;
# Python3 dependencies
python3Dependencies = let
deps = map (p: p.plugin.python3Dependencies or (_: [])) plugins;
in
ps: builtins.concatMap (f: f ps) deps;
# Combined plugin
combinedPlugin = pkgs.vimUtils.toVimPlugin (
pkgs.buildEnv {
name = "plugin-pack";
paths = overriddenPlugins;
inherit pathsToLink;
# Remove empty directories and activate vimGenDocHook
postBuild = ''
find $out -type d -empty -delete
runHook preFixup
'';
passthru = {
inherit python3Dependencies;
};
}
);
# Combined plugin configs
combinedConfig = builtins.concatStringsSep "\n" (
builtins.concatMap (x: lib.optional (x.config != null && x.config != "") x.config) plugins
);
in {
plugin = combinedPlugin;
config = combinedConfig;
optional = false;
};
}