blob: c30db53a443a3ae219393c6cdfb618c833095ba8 (
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,
lib,
inputs,
pkgs,
...
}: let
inherit (lib.options) literalExpression mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.attrsets) genAttrs;
inherit (lib.types) enum listOf;
inherit (lib.nvim.types) mkCustomGrammarOption;
cfg = config.vim.languages.asciidoc;
defaultFormat = ["injected"];
formats = ["injected"];
in {
options.vim.languages.asciidoc = {
enable = mkEnableOption "AsciiDoc support";
treesitter = {
enable =
mkEnableOption "AsciiDoc treesitter"
// {
default = config.vim.languages.enableTreesitter;
defaultText = literalExpression "config.vim.languages.enableTreesitter";
};
blockPackage = mkCustomGrammarOption inputs pkgs "asciidoc";
inlinePackage = mkCustomGrammarOption inputs pkgs "asciidoc-inline";
};
format = {
enable =
mkEnableOption "AsciiDoc formatting"
// {
default = config.vim.languages.enableFormat;
defaultText = literalExpression "config.vim.languages.enableFormat";
};
type = mkOption {
description = "AsciiDoc formatter to use";
type = listOf (enum formats);
default = defaultFormat;
};
};
};
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim.treesitter = {
enable = true;
grammars = [
cfg.treesitter.blockPackage
cfg.treesitter.inlinePackage
];
};
})
(mkIf cfg.format.enable {
vim.formatter.conform-nvim = {
enable = true;
presets = genAttrs cfg.format.type (_: {enable = true;});
setupOpts.formatters_by_ft.asciidoc = cfg.format.type;
};
})
]);
}
|