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 all 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
88 changes: 81 additions & 7 deletions boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
from .plugin.configuration import LspDisableLanguageServerInProjectCommand
from .plugin.configuration import LspEnableLanguageServerGloballyCommand
from .plugin.configuration import LspEnableLanguageServerInProjectCommand
from .plugin.core.collections import DottedDict
from .plugin.core.css import load as load_css
from .plugin.core.open import opening_files
from .plugin.core.panels import PanelName
from .plugin.core.protocol import Error
from .plugin.core.registry import LspNextDiagnosticCommand
from .plugin.core.registry import LspOpenLocationCommand
from .plugin.core.registry import LspPrevDiagnosticCommand
Expand Down Expand Up @@ -86,10 +84,86 @@
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__ = (
"DocumentSyncListener",
"Listener",
"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",
"TextChangeListener",
"plugin_loaded",
"plugin_unloaded",
)
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 +173,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 +186,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 +207,6 @@ def plugin_unloaded() -> None:


class Listener(sublime_plugin.EventListener):

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

Expand Down Expand Up @@ -187,7 +261,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