/
config.ts
110 lines (98 loc) · 2.42 KB
/
config.ts
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
import {
BaseConfig,
ConfigArguments,
ConfigReturn,
Denops,
gatherCheckFiles,
gatherTomls,
gatherVimrcs,
join,
LazyMakeStateResult,
Plugin,
Toml,
vars,
VimrcSkipRule,
} from "./deps.ts";
export class Config extends BaseConfig {
override async config(args: ConfigArguments): Promise<ConfigReturn> {
const denops: Denops = args.denops;
const vimrcSkipRules = [
{
name: "neovide.lua",
condition: await vars.globals.get(denops, "neovide") === null,
},
] as VimrcSkipRule[];
const inlineVimrcs: string[] = gatherVimrcs(
await vars.g.get(denops, "rc_dir"),
vimrcSkipRules,
);
args.contextBuilder.setGlobal({
inlineVimrcs: inlineVimrcs,
protocols: ["git"],
protocolParams: {
git: {
enablePartialClone: true,
},
},
extParams: {
installer: {
checkDiff: true,
logFilePath: join(
await vars.globals.get(denops, "dpp_cache"),
// installer_{YYYYMMDD}.log
`installer_${
new Date().toLocaleDateString("ja-JP", {
year: "numeric",
month: "2-digit",
day: "2-digit",
}).replaceAll("/", "")
}.log`,
),
},
},
});
const tomls = await gatherTomls(
await vars.globals.get(denops, "toml_dir"),
["dpp.toml", "no_lazy.toml"],
args,
) as Toml[];
const recordPlugins: Record<string, Plugin> = {};
const hooksFiles: string[] = [];
for (const toml of tomls) {
if (toml.plugins) {
for (const plugin of toml.plugins) {
recordPlugins[plugin.name] = plugin;
}
}
if (toml.hooks_file) {
hooksFiles.push(toml.hooks_file);
}
}
const [context, options] = await args.contextBuilder.get(denops);
const lazyResult = await args.dpp.extAction(
denops,
context,
options,
"lazy",
"makeState",
{
plugins: Object.values(recordPlugins),
},
) as LazyMakeStateResult | undefined;
const checkFiles = gatherCheckFiles(
denops,
await vars.g.get(denops, "base_dir"),
[
"**/*.lua",
"**/*.toml",
"**/*.ts",
],
);
return {
checkFiles: await checkFiles,
hooksFiles,
plugins: lazyResult?.plugins ?? [],
stateLines: lazyResult?.stateLines ?? [],
};
}
}