Skip to content

Commit cfeac1c

Browse files
committed
fix error
1 parent 669ff50 commit cfeac1c

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

script/plugin.lua

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,24 +84,30 @@ local function initPlugin(uri)
8484
local scp = scope.getScope(uri)
8585
local interfaces = {}
8686
scp:set('pluginInterfaces', interfaces)
87-
87+
8888
if not scp.uri then
8989
return
9090
end
9191
---@type string[]|string
9292
local pluginConfigPaths = config.get(scp.uri, 'Lua.runtime.plugin')
93+
if not pluginConfigPaths then
94+
return
95+
end
9396
local args = config.get(scp.uri, 'Lua.runtime.pluginArgs')
9497
if type(pluginConfigPaths) == 'string' then
95-
pluginConfigPaths = {pluginConfigPaths}
98+
pluginConfigPaths = { pluginConfigPaths }
9699
end
97100
for i, pluginConfigPath in ipairs(pluginConfigPaths) do
98101
local myArgs = args
99-
for k, v in pairs(args) do
100-
if pluginConfigPath:find(k, 1, true) then
101-
myArgs = v
102-
break
102+
if args then
103+
for k, v in pairs(args) do
104+
if pluginConfigPath:find(k, 1, true) then
105+
myArgs = v
106+
break
107+
end
103108
end
104109
end
110+
105111
local pluginPath = ws.getAbsolutePath(scp.uri, pluginConfigPath)
106112
log.info('plugin path:', pluginPath)
107113
if not pluginPath then
@@ -126,7 +132,7 @@ local function initPlugin(uri)
126132
scp:set('pluginPath', pluginPath)
127133

128134
local interface = setmetatable({}, { __index = _ENV })
129-
local f, err = load(pluginLua, '@'..pluginPath, "t", interface)
135+
local f, err = load(pluginLua, '@' .. pluginPath, "t", interface)
130136
if not f then
131137
log.error(err)
132138
m.showError(scp, err)

0 commit comments

Comments
 (0)