mirror of
https://github.com/zoriya/flake.git
synced 2026-08-15 18:43:42 +00:00
Pack every start plugins together
This commit is contained in:
@@ -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
@@ -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
|
||||
|
||||
@@ -2,6 +2,7 @@ return {
|
||||
{
|
||||
"catppuccin-nvim",
|
||||
-- colorscheme = "catppuccin",
|
||||
load = function()end,
|
||||
priority = 1000,
|
||||
opt = {
|
||||
integrations = {
|
||||
|
||||
+19
-14
@@ -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 " " [
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user