diff --git a/bundle/nvim-plug/README.md b/bundle/nvim-plug/README.md index 7838af126..5a9bd2336 100644 --- a/bundle/nvim-plug/README.md +++ b/bundle/nvim-plug/README.md @@ -99,22 +99,25 @@ require('plug').add({ The plugin spec is inspired by dein.nvim. -| name | description | -| ------------- | ---------------------------------------------------------------------------------------------------- | -| `[1]` | `string`, plugin repo short name, `wsdjeg/flygrep.nvim` | -| `cmds` | `table`, commands lazy loading | -| `events` | `table`, events lazy loading | -| `on_ft` | `table`, filetypes lazy loading | -| `on_map` | `table`, key bindings lazy loading | -| `on_func` | `string` or `table`, vim function lazy loading | -| `script_type` | `string`, plugin type including `color`, `plugin`, etc.. | -| `build` | `string` or `table`, executed by [job](https://spacevim.org/api/job/) api | -| `enabled` | `boolean` or `function` evaluated when startup, when it is false, plugin will be skiped | -| `frozen` | update only when specific with `PlugUpdate name` | -| `depends` | `table` a list of plugins | -| `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 | +| name | description | +| --------------- | ------------------------------------------------------------------------------------------------------------- | +| `[1]` | `string`, plugin repo short name, `wsdjeg/flygrep.nvim` | +| `cmds` | `table`, commands lazy loading | +| `events` | `table`, events lazy loading | +| `config` | `function`, function called after adding plugin path to nvim rtp, before loading files in `plugin/` directory | +| `config_after` | `function`, function called after loading files in `plugin/` directory | +| `config_before` | `function`, function called when `plug.add()` function is called | +| `on_ft` | `table`, filetypes lazy loading | +| `on_map` | `table`, key bindings lazy loading | +| `on_func` | `string` or `table`, vim function lazy loading | +| `script_type` | `string`, plugin type including `color`, `plugin`, etc.. | +| `build` | `string` or `table`, executed by [job](https://spacevim.org/api/job/) api | +| `enabled` | `boolean` or `function` evaluated when startup, when it is false, plugin will be skiped | +| `frozen` | update only when specific with `PlugUpdate name` | +| `depends` | `table` a list of plugins | +| `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 | ## Commands diff --git a/bundle/nvim-plug/lua/plug/init.lua b/bundle/nvim-plug/lua/plug/init.lua index a60aea0a0..2bc83f5b5 100644 --- a/bundle/nvim-plug/lua/plug/init.lua +++ b/bundle/nvim-plug/lua/plug/init.lua @@ -18,10 +18,11 @@ function M.setup(opt) end --- @param plugins table -function M.add(plugins) +function M.add(plugins, skip_deps) for _, plug in ipairs(plugins) do - if plug.depends then + if plug.depends and not skip_deps then M.add(plug.depends) + M.add({ plug }, true) else loader.parser(plug) if not plug.enabled then diff --git a/bundle/nvim-plug/lua/plug/loader.lua b/bundle/nvim-plug/lua/plug/loader.lua index e02d64139..c5078fc49 100644 --- a/bundle/nvim-plug/lua/plug/loader.lua +++ b/bundle/nvim-plug/lua/plug/loader.lua @@ -15,7 +15,6 @@ local add_raw_rtp = false --- @field rtp string --- @field events table --- @field cmds table ---- @field config function --- @field name string --- @field branch string --- @field tag string @@ -27,6 +26,10 @@ local add_raw_rtp = false --- @field frozen boolean --- @field type string "git", "raw" or "none" --- @field script_type string "git", "raw" or "none" +--- @field config function function called after update rtp +--- @field config_before function function called after update rtp +--- @field config_after function function called after update rtp +--- @field hook_install_done? function --- @param plugSpec PluginSpec --- @return boolean @@ -91,6 +94,10 @@ function M.parser(plugSpec) plugSpec.url = config.base_url .. '/' .. plugSpec[1] end + if type(plugSpec.config_before) == 'function' then + plugSpec.config_before() + end + return plugSpec end @@ -117,11 +124,17 @@ end function M.load(plugSpec) if plugSpec.rtp and vim.fn.isdirectory(plugSpec.rtp) == 1 then vim.opt.runtimepath:append(plugSpec.rtp) + if type(plugSpec.config) == 'function' then + plugSpec.config() + end if vim.fn.has('vim_starting') ~= 1 then local plugin_directory_files = vim.fn.globpath(plugSpec.rtp, 'plugin/*.{lua,vim}', 0, 1) for _, f in ipairs(plugin_directory_files) do vim.cmd.source(f) end + if type(plugSpec.config_after) == 'function' then + plugSpec.config_after() + end end end end