mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-30 14:47:16 +09:00
@@ -108,17 +108,27 @@ func LoadPlugins() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, pluginName := range preInstalledPlugins {
|
for _, pluginName := range preInstalledPlugins {
|
||||||
plugin := "runtime/plugins/" + pluginName + "/" + pluginName + ".lua"
|
alreadyExists := false
|
||||||
data, err := Asset(plugin)
|
for _, pl := range loadedPlugins {
|
||||||
if err != nil {
|
if pl == pluginName {
|
||||||
TermMessage("Error loading pre-installed plugin: " + pluginName)
|
alreadyExists = true
|
||||||
continue
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pluginDef := "\nlocal P = {}\n" + pluginName + " = P\nsetmetatable(" + pluginName + ", {__index = _G})\nsetfenv(1, P)\n"
|
if !alreadyExists {
|
||||||
if err := L.DoString(pluginDef + string(data)); err != nil {
|
plugin := "runtime/plugins/" + pluginName + "/" + pluginName + ".lua"
|
||||||
TermMessage(err)
|
data, err := Asset(plugin)
|
||||||
continue
|
if err != nil {
|
||||||
|
TermMessage("Error loading pre-installed plugin: " + pluginName)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
pluginDef := "\nlocal P = {}\n" + pluginName + " = P\nsetmetatable(" + pluginName + ", {__index = _G})\nsetfenv(1, P)\n"
|
||||||
|
if err := L.DoString(pluginDef + string(data)); err != nil {
|
||||||
|
TermMessage(err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
loadedPlugins = append(loadedPlugins, pluginName)
|
||||||
}
|
}
|
||||||
loadedPlugins = append(loadedPlugins, pluginName)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user