blob: 3fe946e6e3c88b2f48ba3f7dc8a8405174416802 (
plain)
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
|
{
config,
pkgs,
lib,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.options) mkOption literalExpression;
inherit (lib.strings) concatStringsSep trim;
inherit (lib.attrsets) mapAttrsToList;
inherit (lib.types) attrsOf;
inherit (lib.nvim.types) luaInline;
cfg = config.vim.healthchecks;
in {
options.vim.healthchecks = mkOption {
type = attrsOf (attrsOf luaInline);
default = {};
description = "custom healthchecks to register";
example = literalExpression ''
let
inherit (lib.generators) mkLuaInline;
in
{
nvf = {
"Executables" = mkLuaInline '''
if vim.fn.executable("git") == 1 then
vim.health.ok("git found")
else
vim.health.error("git not found")
end
if vim.fn.executable("pijul") == 1 then
vim.health.ok("pijul found")
else
vim.health.error("pijul not found")
end
''';
"Nixvim" = mkLuaInline '''
vim.health.ok("NVF is better than nixvim")
''';
};
}
'';
};
config = mkIf (cfg != {}) {
vim.additionalRuntimePaths = [
(pkgs.linkFarm "nvf-healthchecks" (mapAttrsToList (name: checks: {
name = "lua/${name}/health.lua";
path = pkgs.writeText "nvf-healthcheck-${name}" ''
local M = {}
M.check = function()
${concatStringsSep "\n" (mapAttrsToList (name: check: ''
vim.health.start("${name}")
${trim check.expr}
'')
checks)}
end
return M
'';
})
cfg))
];
};
}
|