This repository has been archived on 2024-05-17. You can view files and clone it, but cannot push or open issues or pull requests.
neovim/neovim.nix

97 lines
2.1 KiB
Nix

{ enableDevIcons ? false
, enableTabby ? false
, enableOrgMode ? false
, viAlias ? false
, vimAlias ? false
, extraConfig ? ""
, extraLuaConfig ? ""
, extraPlugins ? [ ]
, theme ? { }
, plugins ? { }
, wrapNeovim
, neovim-unwrapped
, tree-sitter
, neovimPlugins
, lib
, nix2lua
, substituteAll
, callPackage
, ...
}:
let
plugins' = plugins;
mergeAttrs = v:
if builtins.isList v then
lib.foldl lib.recursiveUpdate { } (map mergeAttrs v)
else if v ? _type then
if v._type == "merge" then mergeAttrs v.contents
else if v._type == "if" then lib.optionalAttrs v.condition v.content
else builtins.abort "Unsupported attribute"
else v;
in
let
plugins = mergeAttrs plugins';
inherit (builtins) catAttrs readFile;
extLib = import ./lib.nix { inherit lib substituteAll; } // {
inherit (nix2lua.lib) toLua LuaNil;
};
pluginParams = neovimPlugins // {
inherit tree-sitter plugins enableDevIcons enableTabby enableOrgMode;
themeCfg = theme;
lib = extLib;
};
callPlugin = plugin: callPackage plugin pluginParams;
callPlugins = list: map callPlugin list;
pluginsSettings = callPlugins [
./plugins/config
./plugins/syntax
./plugins/git
./plugins/explorer
./plugins/theme
./plugins/lsp
./plugins/formatter
./plugins/ux
];
basePlugins = [ neovimPlugins.plenary-nvim ];
customPlugins = catAttrs "plugins" pluginsSettings;
allPlugins = basePlugins ++ customPlugins ++ extraPlugins;
basicConfigs = map readFile [ ./config/basic.lua ];
pluginConfigs = catAttrs "luaConfig" pluginsSettings;
allConfigs = basicConfigs ++ pluginConfigs ++ [ extraLuaConfig ];
mkLuaHeredoc = content: ''
lua << EOF
${content}
EOF
'';
mkLuaRc = lib.concatMapStrings mkLuaHeredoc;
in
(wrapNeovim neovim-unwrapped {
inherit viAlias;
inherit vimAlias;
withPython3 = false;
withNodeJs = false;
withRuby = false;
configure = {
customRC = extraConfig + mkLuaRc allConfigs;
packages.myVimPackages = { start = allPlugins; };
};
}).overrideAttrs (oldAttrs: {
passthru = oldAttrs.passthru // {
nix2lua = nix2lua.lib;
inherit plugins allConfigs;
};
})