-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use boot.py and plugin/ structure
Signed-off-by: Jack Cherng <jfcherng@gmail.com>
- Loading branch information
Showing
10 changed files
with
91 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from __future__ import annotations | ||
|
||
|
||
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] | ||
|
||
|
||
reload_plugin() | ||
|
||
from .plugin import * # noqa: E402, F401, F403 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from __future__ import annotations | ||
|
||
from .client import LspBasedpyrightPlugin | ||
from .commands import LspBasedpyrightCreateConfigurationCommand | ||
from .listener import LspBasedpyrightEventListener | ||
|
||
__all__ = ( | ||
# ST: core | ||
"plugin_loaded", | ||
"plugin_unloaded", | ||
# ST: commands | ||
"LspBasedpyrightCreateConfigurationCommand", | ||
# ST: listeners | ||
"LspBasedpyrightEventListener", | ||
# ... | ||
"LspBasedpyrightPlugin", | ||
) | ||
|
||
|
||
def plugin_loaded() -> None: | ||
"""Executed when this plugin is loaded.""" | ||
LspBasedpyrightPlugin.setup() | ||
|
||
|
||
def plugin_unloaded() -> None: | ||
"""Executed when this plugin is unloaded.""" | ||
LspBasedpyrightPlugin.window_attrs.clear() | ||
LspBasedpyrightPlugin.cleanup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from __future__ import annotations | ||
|
||
from .lsp_basedpyright_create_configuration import LspBasedpyrightCreateConfigurationCommand | ||
|
||
__all__ = ( | ||
# ST: commands | ||
"LspBasedpyrightCreateConfigurationCommand", | ||
) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from __future__ import annotations | ||
|
||
assert __package__ | ||
|
||
PACKAGE_NAME = __package__.partition(".")[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from __future__ import annotations | ||
|
||
import sublime | ||
import sublime_plugin | ||
|
||
from .client import LspBasedpyrightPlugin | ||
|
||
|
||
class LspBasedpyrightEventListener(sublime_plugin.EventListener): | ||
def on_pre_close_window(self, window: sublime.Window) -> None: | ||
LspBasedpyrightPlugin.window_attrs.pop(window.id(), None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from __future__ import annotations | ||
|
||
import os | ||
import re | ||
import subprocess | ||
from typing import Any | ||
|
||
|
||
def get_default_startupinfo() -> Any: | ||
if os.name == "nt": | ||
# do not create a window for the process | ||
STARTUPINFO = subprocess.STARTUPINFO() # type: ignore | ||
STARTUPINFO.dwFlags |= subprocess.STARTF_USESHOWWINDOW # type: ignore | ||
STARTUPINFO.wShowWindow = subprocess.SW_HIDE # type: ignore | ||
return STARTUPINFO | ||
return None | ||
|
||
|
||
def lowercase_drive_letter(path: str) -> str: | ||
return re.sub(r"^[A-Z]+(?=:\\)", lambda m: m.group(0).lower(), path) |
File renamed without changes.