mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-22 05:13:45 +08:00
feat(nvim-plug): add fetch
option
This commit is contained in:
parent
28562a6de9
commit
3267c9087d
32
bundle/nvim-plug/README.md
vendored
32
bundle/nvim-plug/README.md
vendored
@ -13,6 +13,7 @@
|
||||
- [Installation](#installation)
|
||||
- [Setup nvim-plug](#setup-nvim-plug)
|
||||
- [Add plugins](#add-plugins)
|
||||
- [Self upgrade](#self-upgrade)
|
||||
- [Plugin Spec](#plugin-spec)
|
||||
- [Commands](#commands)
|
||||
- [Default UI](#default-ui)
|
||||
@ -129,12 +130,40 @@ require('plug').add({
|
||||
})
|
||||
```
|
||||
|
||||
### Self upgrade
|
||||
|
||||
you can use nvim-plug to manager nvim-plug:
|
||||
|
||||
```lua
|
||||
if vim.fn.isdirectory('D:/bundle_dir/wsdjeg/nvim-plug') == 0 then
|
||||
vim.fn.system({
|
||||
'git',
|
||||
'clone',
|
||||
'--depth',
|
||||
'1',
|
||||
'https://github.com/wsdjeg/nvim-plug.git',
|
||||
'D:/bundle_dir/wsdjeg/nvim-plug',
|
||||
})
|
||||
end
|
||||
vim.opt.runtimepath:append('D:/bundle_dir/wsdjeg/nvim-plug')
|
||||
require('plug').setup({
|
||||
-- set the bundle dir
|
||||
bundle_dir = 'D:/bundle_dir',
|
||||
})
|
||||
require('plug').add({
|
||||
{
|
||||
'wsdjeg/nvim-plug',
|
||||
fetch = true,
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
## Plugin Spec
|
||||
|
||||
The plugin spec is inspired by [dein.nvim](https://github.com/Shougo/dein.vim).
|
||||
|
||||
| name | description |
|
||||
| --------------- | ------------------------------------------------------------------------------------------------------------- |
|
||||
| --------------- | ---------------------------------------------------------------------------------------------------------------- |
|
||||
| `[1]` | `string`, plugin repo short name, `wsdjeg/flygrep.nvim` |
|
||||
| `cmds` | `string` or `table<string>`, commands lazy loading |
|
||||
| `events` | `string` or `table<string>`, events lazy loading |
|
||||
@ -154,6 +183,7 @@ The plugin spec is inspired by [dein.nvim](https://github.com/Shougo/dein.vim).
|
||||
| `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 |
|
||||
| `priority` | `number`, default is 50, set the order in which plugins are loaded |
|
||||
| `fetch` | If set to true, nvim-plug doesn't add the path to user runtimepath. It is useful to manager no-plugin repository |
|
||||
|
||||
- `config` and `config_after` function will be not be called if the plugin has not been installed.
|
||||
- `priority` does not work for lazy plugins.
|
||||
|
4
bundle/nvim-plug/lua/plug/loader.lua
vendored
4
bundle/nvim-plug/lua/plug/loader.lua
vendored
@ -32,6 +32,7 @@ local loaded_plugins = {}
|
||||
--- @field config_after function function called after update rtp
|
||||
--- @field hook_install_done? function
|
||||
--- @field autoload? boolean
|
||||
--- @field fetch? boolean If set to true, nvim-plug doesn't add the path to user runtimepath, and doesn't load the bundle
|
||||
|
||||
--- @param plugSpec PluginSpec
|
||||
--- @return boolean
|
||||
@ -95,7 +96,7 @@ function M.parser(plugSpec)
|
||||
plugSpec.path = config.bundle_dir .. '/' .. plugSpec[1] .. '/plugin'
|
||||
plugSpec.url = config.base_url .. '/' .. plugSpec[1]
|
||||
end
|
||||
if type(plugSpec.autoload) == 'nil' and plugSpec.type ~= 'raw' then
|
||||
if type(plugSpec.autoload) == 'nil' and plugSpec.type ~= 'raw' and not plugSpec.fetch then
|
||||
plugSpec.autoload = true
|
||||
end
|
||||
|
||||
@ -111,6 +112,7 @@ function M.load(plugSpec)
|
||||
plugSpec.rtp
|
||||
and vim.fn.isdirectory(plugSpec.rtp) == 1
|
||||
and not loaded_plugins[plugSpec.name]
|
||||
and not plugSpec.fetch
|
||||
then
|
||||
vim.opt.runtimepath:append(plugSpec.rtp)
|
||||
loaded_plugins[plugSpec.name] = true
|
||||
|
4
bundle/nvim-plug/test/init.lua
vendored
4
bundle/nvim-plug/test/init.lua
vendored
@ -42,6 +42,10 @@ require('plug').add({
|
||||
'wsdjeg/git.vim',
|
||||
cmds = { 'Git' },
|
||||
},
|
||||
{
|
||||
'wsdjeg/nvim-plug',
|
||||
fetch = true,
|
||||
},
|
||||
{
|
||||
'wsdjeg/JavaUnit.vim',
|
||||
cmds = { 'JavaUnit' },
|
||||
|
Loading…
Reference in New Issue
Block a user