Skip to content

Commit

Permalink
Merge branch 'main' into feat/diag-annotations
Browse files Browse the repository at this point in the history
* main:
  Focus symbol closest to selection on showing document symbols
  Properly handle disabling of the LSP package (#2085)
  fix issues with restarting servers (#2088)
  Add `$line` and `$character` expansion variables (#2092)
  Only enable Goto Diagnostic commands if diagnostic with configured severity exists (#2091)
  Update diagnostics gutter icons and change default to "sign" (#2086)
  Fix short color box rendering bug after color presentation change (#2087)
  • Loading branch information
rchl committed Oct 22, 2022
2 parents 81870b8 + 4b5cf55 commit f9f1c50
Show file tree
Hide file tree
Showing 49 changed files with 561 additions and 966 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
.style.yapf export-ignore
codecov.yml export-ignore
docs/ export-ignore
icons/convert.bat export-ignore
icons/*.svg export-ignore
mypy.ini export-ignore
stubs/ export-ignore
tests/ export-ignore
Expand Down
2 changes: 1 addition & 1 deletion LSP.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@

// Gutter marker for code diagnostics.
// Valid values are "dot", "circle", "bookmark", "sign" or ""
"diagnostics_gutter_marker": "dot",
"diagnostics_gutter_marker": "sign",

// Highlight style of links to internal or external resources, like another text document
// or a web site. Link navigation is implemented via the popup on mouse hover.
Expand Down
54 changes: 28 additions & 26 deletions boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,8 @@
from .plugin.configuration import LspEnableLanguageServerInProjectCommand
from .plugin.core.collections import DottedDict
from .plugin.core.css import load as load_css
from .plugin.core.logging import exception_log
from .plugin.core.open import opening_files
from .plugin.core.panels import destroy_output_panels
from .plugin.core.panels import LspClearLogPanelCommand
from .plugin.core.panels import LspClearPanelCommand
from .plugin.core.panels import LspToggleLogPanelLinesLimitCommand
from .plugin.core.panels import LspUpdatePanelCommand
from .plugin.core.panels import LspUpdateLogPanelCommand
from .plugin.core.panels import PanelName
from .plugin.core.panels import WindowPanelListener
from .plugin.core.protocol import Error
from .plugin.core.protocol import Location
from .plugin.core.protocol import LocationLink
Expand Down Expand Up @@ -58,8 +50,13 @@
from .plugin.goto_diagnostic import LspGotoDiagnosticCommand
from .plugin.hover import LspHoverCommand
from .plugin.inlay_hint import LspInlayHintClickCommand
from .plugin.panels import LspClearLogPanelCommand
from .plugin.panels import LspClearPanelCommand
from .plugin.panels import LspShowDiagnosticsPanelCommand
from .plugin.panels import LspToggleLogPanelLinesLimitCommand
from .plugin.panels import LspToggleServerPanelCommand
from .plugin.panels import LspUpdateLogPanelCommand
from .plugin.panels import LspUpdatePanelCommand
from .plugin.references import LspSymbolReferencesCommand
from .plugin.rename import LspSymbolRenameCommand
from .plugin.save_command import LspSaveAllCommand
Expand Down Expand Up @@ -109,21 +106,14 @@ def _unregister_all_plugins() -> None:
def plugin_loaded() -> None:
load_settings()
load_css()
windows.enable()
_register_all_plugins()
client_configs.update_configs()
for window in sublime.windows():
windows.lookup(window)


def plugin_unloaded() -> None:
_unregister_all_plugins()
for window in sublime.windows():
destroy_output_panels(window) # references and diagnostics panels
try:
windows.lookup(window).plugin_unloaded()
windows.discard(window)
except Exception as ex:
exception_log("failed to unload window", ex)
windows.disable()
unload_settings()


Expand All @@ -133,10 +123,14 @@ def on_exit(self) -> None:
kill_all_subprocesses()

def on_load_project_async(self, w: sublime.Window) -> None:
windows.lookup(w).on_load_project_async()
manager = windows.lookup(w)
if manager:
manager.on_load_project_async()

def on_post_save_project_async(self, w: sublime.Window) -> None:
windows.lookup(w).on_post_save_project_async()
manager = windows.lookup(w)
if manager:
manager.on_post_save_project_async()

def on_new_window_async(self, w: sublime.Window) -> None:
sublime.set_timeout(lambda: windows.lookup(w))
Expand Down Expand Up @@ -180,8 +174,17 @@ def on_pre_close(self, view: sublime.View) -> None:
break

def on_post_window_command(self, window: sublime.Window, command_name: str, args: Optional[Dict[str, Any]]) -> None:
if command_name == "show_panel" and args and args.get("panel") == "output.{}".format(PanelName.Diagnostics):
sublime.set_timeout_async(windows.lookup(window).update_diagnostics_panel_async)
if command_name == "show_panel":
wm = windows.lookup(window)
if not wm:
return
panel_manager = wm.panel_manager
if not panel_manager:
return
if panel_manager.is_panel_open(PanelName.Diagnostics):
sublime.set_timeout_async(wm.update_diagnostics_panel_async)
elif panel_manager.is_panel_open(PanelName.Log):
sublime.set_timeout(panel_manager.update_log_panel)


class LspOpenLocationCommand(sublime_plugin.TextCommand):
Expand All @@ -202,11 +205,10 @@ def run(
def _run_async(
self, location: Union[Location, LocationLink], session_name: Optional[str], flags: int = 0, group: int = -1
) -> None:
window = self.view.window()
if not window:
return
windows.lookup(window).open_location_async(location, session_name, self.view, flags, group).then(
lambda view: self._handle_continuation(location, view is not None))
manager = windows.lookup(self.view.window())
if manager:
manager.open_location_async(location, session_name, self.view, flags, group) \
.then(lambda view: self._handle_continuation(location, view is not None))

def _handle_continuation(self, location: Union[Location, LocationLink], success: bool) -> None:
if not success:
Expand Down
2 changes: 2 additions & 0 deletions docs/src/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,7 @@ You can include special variables in the `command_args` array that will be autom
| `"$selection_begin"` or `"${selection_begin}"` | int | Character offset of the begin of the (topmost) selection |
| `"$selection_end"` or `"${selection_end}"` | int | Character offset of the end of the (topmost) selection |
| `"$position"` or `"${position}"` | object | JSON object `{ 'line': int, 'character': int }` of the (topmost) cursor position, see [Position](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#position) |
| `"$line"` or `"${line}"` | int | Zero-based line number of the (topmost) cursor position, see [Position](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#position) |
| `"$character"` or `"${character}"` | int | Zero-based character offset relative to the current line of the (topmost) cursor position, see [Position](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#position) |
| `"$range"` or `"${range}"` | object | JSON object with `'start'` and `'end'` positions of the (topmost) selection, see [Range](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#range) |
| `"$text_document_position"` or `"${text_document_position}"` | object | JSON object with `'textDocument'` and `'position'` of the (topmost) selection, see [TextDocumentPositionParams](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocumentPositionParams) |
35 changes: 0 additions & 35 deletions icons/COPYRIGHT_NOTICE.md

This file was deleted.

Loading

0 comments on commit f9f1c50

Please sign in to comment.