name string
}
+// a file with the data stored in memory
+type memoryFile struct {
+ name string
+ data []byte
+}
+
+func (mf memoryFile) Name() string {
+ return mf.name
+}
+func (mf memoryFile) Data() ([]byte, error) {
+ return mf.data, nil
+}
+
func (rf realFile) Name() string {
fn := filepath.Base(string(rf))
return fn[:len(fn)-len(filepath.Ext(fn))]
}
add(RTColorscheme, "colorschemes", "*.micro")
- add(RTSyntax, "syntax", "*.micro")
+ add(RTSyntax, "syntax", "*.yaml")
add(RTHelp, "help", "*.md")
// Search configDir for plugin-scripts
files, _ := ioutil.ReadDir(filepath.Join(configDir, "plugins"))
for _, f := range files {
- if f.IsDir() {
+ realpath, _ := filepath.EvalSymlinks(filepath.Join(configDir, "plugins", f.Name()))
+ realpathStat, _ := os.Stat(realpath)
+ if realpathStat.IsDir() {
scriptPath := filepath.Join(configDir, "plugins", f.Name(), f.Name()+".lua")
if _, err := os.Stat(scriptPath); err == nil {
AddRuntimeFile(RTPlugin, realFile(scriptPath))
AddRuntimeFilesFromAssets(filetype, fullpath, pattern)
}
}
+
+// PluginAddRuntimeFileFromMemory adds a file to the runtime files for a plugin from a given string
+func PluginAddRuntimeFileFromMemory(plugin, filetype, filename, data string) {
+ AddRuntimeFile(filetype, memoryFile{filename, []byte(data)})
+}