Skip to content

Commit 3bce0a7

Browse files
authored
feat: support import option (#8)
1 parent 446acd3 commit 3bce0a7

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* [Installation](#installation)
1414
* [Setup nvim-plug](#setup-nvim-plug)
1515
* [Add plugins](#add-plugins)
16+
* [`import` option](#import-option)
1617
* [Self upgrade](#self-upgrade)
1718
* [Plugin Spec](#plugin-spec)
1819
* [Commands](#commands)
@@ -134,6 +135,12 @@ require('plug').add({
134135
})
135136
```
136137

138+
### `import` option
139+
140+
The default `import` option is `plugins` which means nvim-plug will load `PluginSpec` automatically from `plugins` directory im runtimepath.
141+
142+
To use this option, you need to call `plug.load()` function.
143+
137144
### Self upgrade
138145

139146
you can use nvim-plug to manager nvim-plug:
@@ -373,7 +380,6 @@ Love this plugin? Follow [me](https://wsdjeg.net/) on
373380
[GitHub](https://github.com/wsdjeg) and
374381
[Twitter](http://twitter.com/wsdtty).
375382

376-
377383
## Feedback
378384

379385
If you encounter any bugs or have suggestions, please file an issue in the [issue tracker](https://github.com/wsdjeg/nvim-plug/issues).

lua/plug/config.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ M.max_processes = 5
1313
M.base_url = 'https://github.com'
1414
M.ui = 'default'
1515
M.clone_depth = '1'
16+
M.import = 'plugins'
1617
M.enable_priority = false
1718
function M.setup(opt)
1819
M.bundle_dir = opt.bundle_dir or M.bundle_dir

lua/plug/init.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ function M.load()
8585
loader.load(v)
8686
end
8787
end
88+
if config.import then
89+
for _, v in ipairs(vim.api.nvim_get_runtime_file(config.import .. '*.lua', true)) do
90+
local plug = assert(loadfile(v))() ---@type any?
91+
if type(plug) == 'table' and type(plug[1]) == 'string' then
92+
M.add({ plug })
93+
elseif type(plug) == 'table' and type(plug[1]) == 'table' then
94+
M.add(plug)
95+
end
96+
end
97+
end
8898
end
8999

90100
return M

0 commit comments

Comments
 (0)