Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use native types and f-string #2459

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 90 additions & 5 deletions boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,95 @@
from .plugin.tooling import LspOnDoubleClickCommand
from .plugin.tooling import LspParseVscodePackageJson
from .plugin.tooling import LspTroubleshootServerCommand
from typing import Any, Dict, List, Optional, Type
from typing import Any

__all__ = (
"AbstractPlugin",
"client_configs",
"DocumentSyncListener",
"DottedDict",
"Error",
"kill_all_subprocesses",
"load_css",
"load_settings",
"LspApplyDocumentEditCommand",
"LspApplyWorkspaceEditCommand",
"LspCallHierarchyCommand",
"LspClearLogPanelCommand",
"LspClearPanelCommand",
"LspCodeActionsCommand",
"LspCodeLensCommand",
"LspCollapseTreeItemCommand",
"LspColorPresentationCommand",
"LspCommitCompletionWithOppositeInsertMode",
"LspCopyToClipboardFromBase64Command",
"LspDisableLanguageServerGloballyCommand",
"LspDisableLanguageServerInProjectCommand",
"LspDocumentSymbolsCommand",
"LspDumpBufferCapabilities",
"LspDumpWindowConfigs",
"LspEnableLanguageServerGloballyCommand",
"LspEnableLanguageServerInProjectCommand",
"LspExecuteCommand",
"LspExpandSelectionCommand",
"LspExpandTreeItemCommand",
"LspFoldAllCommand",
"LspFoldCommand",
"LspFormatCommand",
"LspFormatDocumentCommand",
"LspFormatDocumentRangeCommand",
"LspGotoDiagnosticCommand",
"LspHideRenameButtonsCommand",
"LspHierarchyToggleCommand",
"LspHoverCommand",
"LspInlayHintClickCommand",
"LspNextDiagnosticCommand",
"LspOnDoubleClickCommand",
"LspOpenLinkCommand",
"LspOpenLocationCommand",
"LspParseVscodePackageJson",
"LspPrevDiagnosticCommand",
"LspRefactorCommand",
"LspResolveDocsCommand",
"LspRestartServerCommand",
"LspRunTextCommandHelperCommand",
"LspSaveAllCommand",
"LspSaveCommand",
"LspSelectCompletionCommand",
"LspSelectionAddCommand",
"LspSelectionClearCommand",
"LspSelectionSetCommand",
"LspShowDiagnosticsPanelCommand",
"LspShowScopeNameCommand",
"LspSignatureHelpNavigateCommand",
"LspSignatureHelpShowCommand",
"LspSourceActionCommand",
"LspSymbolDeclarationCommand",
"LspSymbolDefinitionCommand",
"LspSymbolImplementationCommand",
"LspSymbolReferencesCommand",
"LspSymbolRenameCommand",
"LspSymbolTypeDefinitionCommand",
"LspToggleCodeLensesCommand",
"LspToggleHoverPopupsCommand",
"LspToggleInlayHintsCommand",
"LspToggleLogPanelLinesLimitCommand",
"LspToggleServerPanelCommand",
"LspTroubleshootServerCommand",
"LspTypeHierarchyCommand",
"LspUpdateLogPanelCommand",
"LspUpdatePanelCommand",
"LspWorkspaceSymbolsCommand",
"opening_files",
"PanelName",
"register_plugin",
"TextChangeListener",
"unload_settings",
"windows",
jfcherng marked this conversation as resolved.
Show resolved Hide resolved
)
predragnikolic marked this conversation as resolved.
Show resolved Hide resolved

def _get_final_subclasses(derived: List[Type], results: List[Type]) -> None:

def _get_final_subclasses(derived: list[type], results: list[type]) -> None:
for d in derived:
d_subclasses = d.__subclasses__()
if len(d_subclasses) > 0:
Expand All @@ -99,7 +184,7 @@ def _get_final_subclasses(derived: List[Type], results: List[Type]) -> None:


def _register_all_plugins() -> None:
plugin_classes: List[Type[AbstractPlugin]] = []
plugin_classes: list[type[AbstractPlugin]] = []
_get_final_subclasses(AbstractPlugin.__subclasses__(), plugin_classes)
for plugin_class in plugin_classes:
try:
Expand All @@ -112,6 +197,7 @@ def _register_all_plugins() -> None:

def _unregister_all_plugins() -> None:
from LSP.plugin.core.sessions import _plugins

_plugins.clear()
client_configs.external.clear()
client_configs.all.clear()
Expand All @@ -132,7 +218,6 @@ def plugin_unloaded() -> None:


class Listener(sublime_plugin.EventListener):

def on_exit(self) -> None:
kill_all_subprocesses()

Expand Down Expand Up @@ -187,7 +272,7 @@ def on_pre_close(self, view: sublime.View) -> None:
tup[1](None)
break

def on_post_window_command(self, window: sublime.Window, command_name: str, args: Optional[Dict[str, Any]]) -> None:
def on_post_window_command(self, window: sublime.Window, command_name: str, args: dict[str, Any] | None) -> None:
if command_name == "show_panel":
wm = windows.lookup(window)
if not wm:
Expand Down
Loading
Loading