]> git.lizzy.rs Git - micro.git/blobdiff - cmd/micro/rtfiles.go
Use messenger error instead of termerror
[micro.git] / cmd / micro / rtfiles.go
index 1b8c01f33c78b678dabe2df6d0666e75ea8137ca..a72b6ee35b1299c697a3867e9693cd5f7fac2193 100644 (file)
@@ -37,6 +37,19 @@ type namedFile struct {
        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))]
@@ -120,7 +133,7 @@ func InitRuntimeFiles() {
        }
 
        add(RTColorscheme, "colorschemes", "*.micro")
-       add(RTSyntax, "syntax", "*.micro")
+       add(RTSyntax, "syntax", "*.yaml")
        add(RTHelp, "help", "*.md")
 
        // Search configDir for plugin-scripts
@@ -187,3 +200,8 @@ func PluginAddRuntimeFilesFromDirectory(plugin, filetype, directory, pattern str
                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)})
+}