forked from nix-community/nixvim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoutput.nix
134 lines (119 loc) · 3.27 KB
/
output.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
{
lib,
config,
helpers,
...
}:
let
inherit (lib) types mkOption;
pluginWithConfigType = types.submodule {
options = {
config = mkOption {
type = types.lines;
description = "vimscript for this plugin to be placed in init.vim";
default = "";
};
optional = lib.mkEnableOption "optional" // {
description = "Don't load by default (load with :packadd)";
};
plugin = mkOption {
type = types.package;
description = "vim plugin";
};
};
};
in
{
options = {
extraPlugins = mkOption {
type = with types; listOf (either package pluginWithConfigType);
default = [ ];
description = "List of vim plugins to install";
};
extraPackages = mkOption {
type = with types; listOf (nullOr package);
default = [ ];
description = "Extra packages to be made available to neovim";
apply = builtins.filter (p: p != null);
};
extraPython3Packages = mkOption {
type = with types; functionTo (listOf package);
default = p: [ ];
defaultText = lib.literalExpression "p: with p; [ ]";
description = "Python packages to add to the `PYTHONPATH` of neovim.";
example = lib.literalExpression ''
p: [ p.numpy ]
'';
};
extraConfigLua = mkOption {
type = types.lines;
default = "";
description = "Extra contents for the file";
};
extraConfigLuaPre = mkOption {
type = types.lines;
default = "";
description = "Extra contents for the file before everything else";
};
extraConfigLuaPost = mkOption {
type = types.lines;
default = "";
description = "Extra contents for the file after everything else";
};
extraConfigVim = mkOption {
type = types.lines;
default = "";
description = "Extra contents for the file, in vimscript";
};
type = mkOption {
type = types.enum [
"vim"
"lua"
];
default = "lua";
description = ''
Whether the generated file is a vim or a lua file
Read-only outside of `files` submodules.
'';
readOnly = config.isTopLevel;
};
path = mkOption {
type = types.str;
description = "Path of the file relative to the config directory";
};
content = mkOption {
type = types.str;
description = "The content of the config file";
readOnly = true;
visible = false;
};
extraLuaPackages = mkOption {
type = types.functionTo (types.listOf types.package);
description = "Extra lua packages to include with neovim";
default = _: [ ];
};
};
config = {
content =
if config.type == "lua" then
# Lua
helpers.concatNonEmptyLines [
config.extraConfigLuaPre
(helpers.wrapVimscriptForLua config.extraConfigVim)
config.extraConfigLua
config.extraConfigLuaPost
]
else
# Vimscript
helpers.concatNonEmptyLines [
(helpers.wrapLuaForVimscript config.extraConfigLuaPre)
config.extraConfigVim
(helpers.wrapLuaForVimscript (
helpers.concatNonEmptyLines [
config.extraConfigLua
config.extraConfigLuaPost
]
))
];
};
}