Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

source lua files in load_plugin #1031

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lua/packer/plugin_utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -188,20 +188,23 @@ plugin_utils.load_plugin = function(plugin)
vim.o.runtimepath = vim.o.runtimepath .. ',' .. plugin.install_path
for _, pat in ipairs {
table.concat({ 'plugin', '**/*.vim' }, util.get_separator()),
table.concat({ 'plugin', '**/*.lua' }, util.get_separator()),
table.concat({ 'after', 'plugin', '**/*.vim' }, util.get_separator()),
table.concat({ 'after', 'plugin', '**/*.lua' }, util.get_separator()),
} do
local cmd = vim.endswith(pat, 'lua') and 'luafile' or 'source'
local path = util.join_paths(plugin.install_path, pat)
local glob_ok, files = pcall(vim.fn.glob, path, false, true)
if not glob_ok then
if string.find(files, 'E77') then
vim.cmd('silent exe "source ' .. path .. '"')
vim.cmd('silent exe "' .. cmd .. ' ' .. path .. '"')
else
error(files)
end
elseif #files > 0 then
for _, file in ipairs(files) do
file = file:gsub('\\', '/')
vim.cmd('silent exe "source ' .. file .. '"')
vim.cmd('silent exe "' .. cmd .. ' ' .. file .. '"')
end
end
end
Expand Down