micro icon indicating copy to clipboard operation
micro copied to clipboard

command: Fix `reload` command to correctly initialize and reload all runtime files

Open JoeKar opened this issue 1 year ago • 2 comments

This fix will prevent duplicating runtime files in the moment reload and it will now reload the plugins as well. Now it needs to be discussed if it's really a good idea to export reload to the Lua plugins, because this could lead to unexpected behavior within the plugins.

Fixes #2795 Fixes #3044 Fixes #3059

JoeKar avatar Nov 30 '23 22:11 JoeKar

Do I correctly understand that if my plugin has variable, after reload it will go to it is default state? If yes, it is only guess and should be checked but it will break filemanager plugin. It opens pane and than handles interactions with it via hooks. They depends on a variable tree_view from the plugin. If it is erased, hooks won't be able to work as expected. And I think that proper filemanager reload means uninit everything, close "managed" pane...

Does micro have hook like uninit or stop or close?

In general I am against of giving plugins ability to call reload on their own.

Now it needs to be discussed if it's really a good idea to export reload to the Lua plugins, because this could lead to unexpected behavior within the plugins.

I just thought, it seems that reload for everything can be unexpected for plugins and especially for user that decided to make reload with opened plugins. Did you meant it? That plugins are built with idea that user will shoot his foot with just reload? You are right. I can propose to add parameters for reload like reload all, reload plugins, reload colors...

dustdfg avatar Dec 01 '23 06:12 dustdfg

Does micro have hook like uninit or stop or close?

It uses the deinit callback/hook, which I didn't add so far. Good point.

In general I am against of giving plugins ability to call reload on their own.

Maybe we can have both. In the moment the user calls the command reload then this should reload plugins as well, because they are included in the runtime files. This includes the use case in which someone writes a plugin in micro and want it to being available after calling reload. The plugins on the other side currently only receive ReloadConfig as exported function, which might be handy to reload the configuration only, which is expected.

This then wouldn't even violate the documentation:

JoeKar avatar Dec 01 '23 17:12 JoeKar