Accessing plugin directory
I'm not sure if I missed something in the docs; is there a better way to access the path of a plugin than hard coding it with config.ConfigDir .. "/plug/mypluginnamehere"?
I'm reviving Palettero and trying to find a way to load configs from its plugin directory without hardcoding the path. AddRuntimeFilesFromDirectory looks tantalizingly close but ListRuntimeFiles only returns the basename and contents (might be enough anyway) without full path.
@dmaluka @JoeKar Is there another recommended way? You're the most active lately and wondered who might know. I checked Discussions and Gitter but it's inactive.
I'm afraid AddRuntimeFilesFromDirectory and friends are not what you need. They only deal with micro's specific file formats (RTColorscheme, RTSyntax, RTHelp, RTPlugin), not with arbitrary config files.
is there a better way to access the path of a plugin than hard coding it with
config.ConfigDir .. "/plug/mypluginnamehere"
Since micro allows using Go filepath package from lua, I suppose you could do that in a slightly more elegant and portable way: filepath.Join(config.ConfigDir, "plug", "mypluginnamehere").
They only deal with micro's specific file formats (
RTColorscheme,RTSyntax,RTHelp,RTPlugin), not with arbitrary config files.
I haven't tested yet but arbitrary formats can be created with NewRTFiletype. Using its file contents may work for my specific use case.
I suppose you could do that in a slightly more elegant and portable way:
filepath.Join(config.ConfigDir, "plug", "mypluginnamehere").
It doesn't resolve the underlying issue. New users (from personal experience) install by cloning (for example old issues about symlinking plugins) because pluginrepos is under-documented. But plugin repos are usually prefixed with micro- and sometimes suffixed with -plugin. The hard coded path would fail.
I haven't tested yet but arbitrary formats can be created with
NewRTFiletype. Using its file contents may work for my specific use case.
Hmm, interesting, I wasn't aware of that. You can try.