dynamic reload?
is there a way for micro to reload dynamically or reload it via the terminal while a session is open?
I want to use matugen to dynamically change the theme but micro doesnt reload dynamically and I have to use the reload command :/
https://github.com/user-attachments/assets/8f0de403-eef1-4940-90a3-e97f3e7f504c
This essentially boils down to a question how to send a command to micro remotely, via a socket or something. I don't think there is such a possibility, unfortunately.
My knowledge of Micro is about the same as my knowledge of ricing—almost zero. Still, I had an idea you could use as a last resort.
If there's no direct way to send a command to Micro, as a final option, you might be able to make Micro reload itself—maybe through an infinite reload loop or by using a file as a socket.
I’m not sure how to implement this properly, but I had an idea. Once this https://github.com/zyedidia/micro/pull/3733. gets merged , you could create an overlay that reloads the config continuously or read the content of a file and reload with some condition. It’s definitely not a clean solution, but I tested it and it seems to work.
At least with a Lua plugin someone could implement the necessary interface and access whatever micro exports. It is limited what micro exports, but it is much more than nothing.
Once this #3733. gets merged , you could create an overlay that reloads the config continuously or read the content of a file and reload with some condition.
You mean, a plugin continuously calling ReloadCmd() in a busy loop? I'm not sure what overlays have to do with that, but anyway that would be a really bad idea (I hope I don't need to explain why).
Or you could do that at regular time intervals (I think you can already do that, using a timer, with After()), that would be not as bad, but still feels quite silly.
A better approach would be to use something like https://pkg.go.dev/github.com/fsnotify/fsnotify...
You mean, a plugin continuously calling
ReloadCmd()in a busy loop? I'm not sure what overlays have to do with that, but anyway that would be a really bad idea (I hope I don't need to explain why).
kinda, callingconfig.Reload()(maybe not in every iteration)
I've mention overlays, because I think a plugin with a busy loop would freeze micro, right?
Or you could do that at regular time intervals (I think you can already do that, using a timer, with
After()), that would be not as bad, but still feels quite silly.
Could you provide a short snippet or describe a bit more that approach by any chance? It might be silly but I got curious 😆
Could you provide a short snippet or describe a bit more that approach by any chance?
local time = import("time")
local interval = time.ParseDuration("1s")
local function periodicReload()
config.Reload()
micro.After(interval, periodicReload)
end
function init()
micro.After(interval, periodicReload)
end
BTW please ignore my above suggestion to use ReloadCmd(), it does exactly what the reload command does, so it would not just reload config files but also reinitialize all plugins, including your plugin which calls it, which is probably a bad idea, so you should use config.Reload() which just reloads config files (and it exists specifically for use by plugins).
BTW please ignore my above suggestion to use
ReloadCmd(), it does exactly what thereloadcommand does, so it would not just reload config files but also reinitialize all plugins, including your plugin which calls it, which is probably a bad idea, so you should useconfig.Reload()which just reloads config files (and it exists specifically for use by plugins).
Ty, that's definitely a better approach, although I've noticed whenconfig.Reload() is called my other plugins don't really work.
when
config.Reload()is called my other plugins don't really work.
Sounds like a bug.
You could define SIGUSR1 to reload the config. That is what kitty does. I don't know however if the signals are taken yet however.