From 812d72d05708c6c80a95f52d0ccce2465e028e51 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 9 Feb 2025 22:36:25 +0800 Subject: [PATCH] feat(nvim-plug): load plugin after installation --- bundle/nvim-plug/README.md | 3 +++ bundle/nvim-plug/lua/plug/installer.lua | 3 +++ bundle/nvim-plug/lua/plug/loader.lua | 1 + bundle/nvim-plug/test/init.lua | 7 +++++++ 4 files changed, 14 insertions(+) diff --git a/bundle/nvim-plug/README.md b/bundle/nvim-plug/README.md index 5a9bd2336..a3a3d25f9 100644 --- a/bundle/nvim-plug/README.md +++ b/bundle/nvim-plug/README.md @@ -118,6 +118,9 @@ The plugin spec is inspired by dein.nvim. | `branch` | `string` specific git branch | | `tag` | `string` specific git tag | | `type` | `string` specific plugin type, this can be git, raw or none, if it is raw, `script_type` must be set | +| `autoload` | `boolean`, load plugin after git clone | + +`config` and `config_after` function will be not be called if the plugin has not been installed. ## Commands diff --git a/bundle/nvim-plug/lua/plug/installer.lua b/bundle/nvim-plug/lua/plug/installer.lua index 25779e807..34ceb8a03 100644 --- a/bundle/nvim-plug/lua/plug/installer.lua +++ b/bundle/nvim-plug/lua/plug/installer.lua @@ -13,6 +13,7 @@ local job = require('spacevim.api.job') local notify = require('spacevim.api.notify') local jobs = {} local config = require('plug.config') +local loader = require('plug.loader') local on_uidate @@ -155,6 +156,8 @@ function H.install_plugin(plugSpec) on_uidate(plugSpec.name, { clone_done = true, download_process = 100 }) if plugSpec.build then H.build(plugSpec) + elseif plugSpec.autoload then + loader.load(plugSpec) end else on_uidate(plugSpec.name, { clone_done = false, download_process = 0 }) diff --git a/bundle/nvim-plug/lua/plug/loader.lua b/bundle/nvim-plug/lua/plug/loader.lua index c5078fc49..39d09d75d 100644 --- a/bundle/nvim-plug/lua/plug/loader.lua +++ b/bundle/nvim-plug/lua/plug/loader.lua @@ -30,6 +30,7 @@ local add_raw_rtp = false --- @field config_before function function called after update rtp --- @field config_after function function called after update rtp --- @field hook_install_done? function +--- @field autoload? boolean --- @param plugSpec PluginSpec --- @return boolean diff --git a/bundle/nvim-plug/test/init.lua b/bundle/nvim-plug/test/init.lua index 947f8dc13..ca13926e4 100644 --- a/bundle/nvim-plug/test/init.lua +++ b/bundle/nvim-plug/test/init.lua @@ -51,6 +51,13 @@ require('plug').add({ events = { 'VimEnter' }, config = function() end, }, + { + 'rakr/vim-one', + events = { 'VimEnter' }, + config = function() + vim.cmd('colorscheme one') + end, + }, { 'wsdjeg/flygrep.nvim', cmds = { 'FlyGrep' },