From 901d47561c43398978df2e9789283e286abc6b41 Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Mon, 13 May 2024 18:52:26 +0900 Subject: [PATCH] Merge non lazy plugins hook_source --- denops/dpp/dpp.ts | 21 ++++++++++++++++----- doc/dpp.txt | 4 ++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/denops/dpp/dpp.ts b/denops/dpp/dpp.ts index b7fbed4..16addd4 100644 --- a/denops/dpp/dpp.ts +++ b/denops/dpp/dpp.ts @@ -164,11 +164,11 @@ export class Dpp { // Add plugins runtimepath const depends = new Set(); - for ( - const plugin of Object.values(recordPlugins).filter((plugin) => - !plugin.lazy - ) - ) { + const nonLazyPlugins = Object.values(recordPlugins).filter((plugin) => + !plugin.lazy + ); + const hookSources = []; + for (const plugin of nonLazyPlugins) { if ( !plugin.rtp || !await isDirectory(plugin.rtp) || !await checkIf(plugin) ) { @@ -179,6 +179,10 @@ export class Dpp { depends.add(depend); } + if (plugin.hook_source) { + hookSources.push(plugin.hook_source); + } + await addRtp(plugin); } @@ -202,6 +206,10 @@ export class Dpp { } await addRtp(plugin); + + if (plugin.hook_source) { + hookSources.push(plugin.hook_source); + } } rtps.splice(rtps.indexOf(runtimePath), 0, dppRuntimepath); @@ -307,6 +315,9 @@ export class Dpp { } } + // Merge non lazy plugins hook_source + startupLines = startupLines.concat(hookSources); + // Write startup script const startupFile = `${basePath}/${name}/startup.vim`; await Deno.writeTextFile(startupFile, startupLines.join("\n")); diff --git a/doc/dpp.txt b/doc/dpp.txt index 579cc51..f9c96f7 100644 --- a/doc/dpp.txt +++ b/doc/dpp.txt @@ -519,8 +519,8 @@ hook_source (String) or (Function) It is executed after plugin runtimepath is added and before the plugin script files are sourced. It is mainly used for plugin configure. - NOTE: The "sourced" means after |dpp#min#load_state()| or when - |VimEnter| or autoloaded. + NOTE: The "sourced" means after |dpp#min#load_state()| or + autoloaded. *dpp-plugin-option-lua_add* lua_add (String)