pjeby / hot-reload

Automatically reload Obsidian plugins in development when their files are changed
ISC License
496 stars 23 forks source link

Add hotkeys for reloading plugins manually? #3

Closed Taitava closed 3 weeks ago

Taitava commented 1 year ago

Hi,

this idea just came to mind. I often need to reload my plugin even if I haven't changed its source code. For example, I might change my plugin's settings file's content manually (outside Obsidian) and then would like to reload the plugin to test that the plugin loads the updated settings file without errors.

Currently I'm using Obsidian's Reload app without saving command, but that's a bit of an overkill when only needing to reload a plugin, as often any current file views go to different scroll positions etc. It would be more convenient to have a hotkey for reloading a specific community plugin.

Thank you for considering this! 🙂

pjeby commented 1 year ago

My suggestion would be to either 1) change the source or otherwise force a rebuild, or 2) add a command to your plugin that does the reload (by disable/enable as shown in this plugin's reload() method).

What I do mostly is variant 1 - i.e., I add a space to the end of a line and then save my plugin so it rebuilds, then I undo the change

pjeby commented 3 weeks ago

Closing this since now there is also a keyboard command to force a scan for plugin changes. It doesn't do exactly what's wanted here, but this is about as close as we're ever going to get to that. (Reloading based on data changes is out of scope for this plugin.)