nim-lang / NimLime

The official Nim programming language plugin for Sublime Text
MIT License
132 stars 34 forks source link

how to reload NimLime without re-opening sublimetext? #115

Closed timotheecour closed 5 years ago

timotheecour commented 5 years ago

I even tried AutomaticPackageReloader but didn't work see https://github.com/randy3k/AutomaticPackageReloader/issues/15

also tried various stuff here https://forum.sublimetext.com/t/how-can-i-reload-a-plugin-in-sublime-console/34325

Varriount commented 5 years ago

Fixed in https://github.com/Varriount/NimLime/commit/54337b88cb8e57c5886746808ce7522da0d9d960 .

timotheecour commented 5 years ago

for reference:

edit $nim_D/NimLime/core/commands/nimcheck.py (eg: change msg here: sublime.status_message('Nim Check Finished.') then in sublime console:

import sublime_plugin
sublime_plugin.reload_plugin('NimLime.core.commands.nimcheck')

then the changes will take effect.

calling the cmd package_reloader_reload from AutomaticPackageReloader (modulo this fix https://github.com/randy3k/AutomaticPackageReloader/pull/17 in case there are symlinks):

[Package Reloader] begin ======================================================
reloading plugin NimLime.NimLime
[Package Reloader] reloading |-- NimLime
[Package Reloader] reloading |-- NimLime.NimLime
[Package Reloader] reloading | |-- NimLime.core
[Package Reloader] reloading | |-- NimLime.core.commands
[Package Reloader] reloading | | |-- NimLime.core.utils
[Package Reloader] reloading | | |-- NimLime.core.utils.misc
[Package Reloader] reloading | | |-- NimLime.core.settings
[Package Reloader] reloading | | |-- NimLime.core.configuration
[Package Reloader] reloading | | |-- NimLime.core.utils.error_handler
[Package Reloader] reloading | | |-- NimLime.core.utils.mixins
[Package Reloader] reloading | | |-- NimLime.core.utils.project
[Package Reloader] installing dummy package
reloading plugin _dummy_package
[Package Reloader] removing dummy package
unloading plugin _dummy_package
[Package Reloader] end --------------------------------------------------------

as you see above, I'm not seeing NimLime.core.commands.nimcheck in the above log /cc @randy3k

so the safest seems to be running sublime_plugin.reload_plugin('NimLime.core.commands.nimcheck')

Varriount commented 5 years ago

Even though the modules themselves don't appear in the above log, they do appear to be reloaded:

randy3k commented 5 years ago

It’s because NimLime.core.commands has a custom loader https://github.com/Varriount/NimLime/blob/master/nimlime_core/commands/__init__.py

Varriount commented 5 years ago

See https://github.com/randy3k/AutomaticPackageReloader/issues/19