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

98 lines
2.1 KiB
Nix
Raw Normal View History

2022-11-30 22:49:32 +03:00
{ enableDevIcons ? false
, enableTabby ? false
, enableOrgMode ? false
, viAlias ? false
, vimAlias ? false
2022-11-30 22:52:01 +03:00
, extraConfig ? ""
, extraLuaConfig ? ""
2022-11-30 22:52:01 +03:00
, extraPlugins ? [ ]
2022-11-30 22:49:32 +03:00
, theme ? { }
, plugins ? { }
, wrapNeovim
, neovim-unwrapped
, tree-sitter
, neovimPlugins
, lib
, nix2lua
, substituteAll
2023-05-23 00:19:13 +03:00
, callPackage
2022-11-30 22:49:32 +03:00
, ...
}:
let
2024-04-16 16:17:45 +03:00
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';
2023-05-23 00:19:13 +03:00
inherit (builtins) catAttrs readFile;
2024-04-16 18:54:21 +03:00
extLib = import ./lib.nix { inherit lib substituteAll; } // {
inherit (nix2lua.lib) toLua LuaNil;
2022-11-30 22:49:32 +03:00
};
2024-04-16 16:17:45 +03:00
2022-11-30 22:49:32 +03:00
pluginParams = neovimPlugins // {
2023-05-23 00:19:13 +03:00
inherit tree-sitter plugins enableDevIcons enableTabby enableOrgMode;
2022-11-30 22:49:32 +03:00
themeCfg = theme;
2024-04-16 18:54:21 +03:00
lib = extLib;
2022-11-30 22:49:32 +03:00
};
2023-05-23 00:19:13 +03:00
callPlugin = plugin: callPackage plugin pluginParams;
2022-11-30 22:49:32 +03:00
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;
2022-11-30 22:52:01 +03:00
allPlugins = basePlugins ++ customPlugins ++ extraPlugins;
2022-11-30 22:49:32 +03:00
basicConfigs = map readFile [ ./config/basic.lua ];
pluginConfigs = catAttrs "luaConfig" pluginsSettings;
allConfigs = basicConfigs ++ pluginConfigs ++ [ extraLuaConfig ];
2024-04-16 18:54:21 +03:00
mkLuaHeredoc = content: ''
lua << EOF
${content}
EOF
'';
mkLuaRc = lib.concatMapStrings mkLuaHeredoc;
2022-11-30 22:49:32 +03:00
in
(wrapNeovim neovim-unwrapped {
inherit viAlias;
inherit vimAlias;
withPython3 = false;
2023-06-09 15:31:58 +03:00
withNodeJs = false;
2022-11-30 22:49:32 +03:00
withRuby = false;
configure = {
2024-04-16 18:54:21 +03:00
customRC = extraConfig + mkLuaRc allConfigs;
2022-11-30 22:49:32 +03:00
packages.myVimPackages = { start = allPlugins; };
};
}).overrideAttrs (oldAttrs: {
passthru = oldAttrs.passthru // {
nix2lua = nix2lua.lib;
2024-04-16 18:54:21 +03:00
inherit plugins allConfigs;
2022-11-30 22:49:32 +03:00
};
})