Skip to content

Commit

Permalink
Add getLazyPlugins
Browse files Browse the repository at this point in the history
  • Loading branch information
Shougo committed Oct 24, 2023
1 parent 14aa60d commit 6a61e85
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
14 changes: 3 additions & 11 deletions denops/dpp/dpp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,17 +667,9 @@ function initPlugin(plugin: Plugin, basePath: string): Plugin {
}

if (!plugin.lazy) {
plugin.lazy = [
"on_ft",
"on_cmd",
"on_func",
"on_lua",
"on_map",
"on_path",
"on_if",
"on_event",
"on_source",
].filter((key) => key in plugin).length > 0;
plugin.lazy = Object.keys(plugin).filter((key) =>
key.startsWith("on_")
).length > 0;
}

if (!plugin.merged) {
Expand Down
7 changes: 7 additions & 0 deletions denops/dpp/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ export function parseHooksFile(
return options;
}

export function getLazyPlugins(plugins: Plugin[]): Plugin[] {
return plugins.filter((plugin) =>
plugin.lazy ||
Object.keys(plugin).filter((key) => key.startsWith("on_")).length > 0
);
}

Deno.test("parseHooksFile", () => {
assertEquals(
parseHooksFile("{{{,}}}", [
Expand Down

0 comments on commit 6a61e85

Please sign in to comment.