This repository has been archived by the owner on May 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib.nix
93 lines (82 loc) · 2.16 KB
/
lib.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
{ pkgs, inputs, ... }:
let
inherit (pkgs.lib) evalModules;
in
{
withPlugins = cond: plugins: if cond then plugins else [ ];
writeIf = cond: msg: if cond then msg else "";
withAttrSet = cond: attrSet: if cond then attrSet else { };
mkVimBool = val: if val then 1 else 0;
mkNeovim = { config }:
let
plugins = pkgs.neovimPlugins;
vimOpts = evalModules {
modules = [
{ imports = [ ./modules ]; }
config
];
specialArgs = {
inherit pkgs;
};
};
vim = vimOpts.config.vim;
in
pkgs.wrapNeovim pkgs.neovim-unwrapped {
inherit (vim) viAlias vimAlias;
withNodeJs = true;
withPython3 = true;
configure = {
customRC = vim.configRC;
packages.myVimPackage = with plugins; {
start = builtins.filter (f: f != null) vim.startPlugins;
opt = vim.optPlugins;
};
};
};
buildPluginOverlay = super: self:
let
inherit (builtins) attrNames filter listToAttrs;
inherit (self.vimUtils) buildVimPluginFrom2Nix;
treesitterGrammars = self.tree-sitter.withPlugins (p: with p; [
tree-sitter-bash
tree-sitter-c
tree-sitter-css
tree-sitter-dockerfile
tree-sitter-elixir
tree-sitter-fish
tree-sitter-haskell
tree-sitter-html
tree-sitter-javascript
tree-sitter-json
tree-sitter-lua
tree-sitter-nix
tree-sitter-rust
tree-sitter-toml
tree-sitter-typescript
tree-sitter-yaml
]);
buildPlug = name: buildVimPluginFrom2Nix {
pname = name;
version = "HEAD";
src = builtins.getAttr name inputs;
postPatch =
if (name == "nvim-treesitter")
then ''
rm -r parser
ln -s ${treesitterGrammars} parser
''
else "";
};
isPlugin = n: n != "neovim" && n != "nixpkgs";
plugins = filter isPlugin (attrNames inputs);
in
{
neovimPlugins = listToAttrs
(map
(name: {
inherit name;
value = buildPlug name;
})
plugins);
};
}