Skip to content

Commit

Permalink
refactor: simplify boot.py
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Cherng <jfcherng@gmail.com>
  • Loading branch information
jfcherng committed Mar 8, 2022
1 parent 7d38c7a commit 17008f6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
18 changes: 4 additions & 14 deletions boot.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
def plugin_reload() -> None:
def reload_plugin() -> None:
import sys

# Remove all previously loaded plugin modules.
prefix = f"{__package__}."
for module_name in tuple(filter(lambda m: m.startswith(prefix) and m != __name__, sys.modules)):
del sys.modules[module_name]


plugin_reload()
reload_plugin()

from .plugin import set_up
from .plugin import tear_down
from .plugin.FollowLnk import * # noqa: F401, F403
import sublime


def plugin_loaded() -> None:
sublime.set_timeout_async(set_up)


def plugin_unloaded() -> None:
tear_down()
from .plugin import * # noqa: F401, F403
18 changes: 14 additions & 4 deletions plugin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
def set_up() -> None:
"""plugin_loaded"""
# import all listeners and commands
from .listener import FollowLnkViewEventListener

__all__ = (
# ST: core
"plugin_loaded",
"plugin_unloaded",
# ST: listeners
"FollowLnkViewEventListener",
)


def plugin_loaded() -> None:
pass


def tear_down() -> None:
"""plugin_unloaded"""
def plugin_unloaded() -> None:
pass
2 changes: 1 addition & 1 deletion plugin/FollowLnk.py → plugin/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
PACKAGE_NAME = __package__.partition(".")[0]


class FollowLnk(sublime_plugin.ViewEventListener):
class FollowLnkViewEventListener(sublime_plugin.ViewEventListener):
@classmethod
def is_applicable(cls, settings: sublime.Settings) -> bool:
return sublime.platform() == "windows"
Expand Down

0 comments on commit 17008f6

Please sign in to comment.