From 17626d5e26373c409e3649b92048d51e429b8878 Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Sun, 28 Jan 2024 23:23:07 +0100 Subject: [PATCH 01/10] add commands for opening "find references" in bottom or quick panel --- Context.sublime-menu | 14 ++++++++++++++ Default.sublime-commands | 14 ++++++++++++++ Main.sublime-menu | 26 ++++++++++++++++++-------- docs/src/keyboard_shortcuts.md | 2 +- plugin/references.py | 30 +++++++++++++++++++++++------- 5 files changed, 70 insertions(+), 16 deletions(-) diff --git a/Context.sublime-menu b/Context.sublime-menu index ba686b208..925923fad 100644 --- a/Context.sublime-menu +++ b/Context.sublime-menu @@ -7,6 +7,20 @@ "command": "lsp_symbol_references", "caption": "Find References" }, + { + "command": "lsp_symbol_references", + "caption": "Find References (in bottom panel)", + "args": { + "show_in": "bottom_panel" + }, + }, + { + "command": "lsp_symbol_references", + "caption": "Find References (in quick panel)", + "args": { + "show_in": "quick_panel" + }, + }, { "command": "lsp_symbol_definition", "caption": "Goto Definition…" diff --git a/Default.sublime-commands b/Default.sublime-commands index 610d5cbab..ee307c686 100644 --- a/Default.sublime-commands +++ b/Default.sublime-commands @@ -121,6 +121,20 @@ "caption": "LSP: Find References", "command": "lsp_symbol_references" }, + { + "caption": "LSP: Find References (in bottom panel)", + "command": "lsp_symbol_references", + "args": { + "show_in": "bottom_panel" + }, + }, + { + "caption": "LSP: Find References (in quick panel)", + "command": "lsp_symbol_references", + "args": { + "show_in": "quick_panel" + }, + }, { "caption": "LSP: Follow Link", "command": "lsp_open_link" diff --git a/Main.sublime-menu b/Main.sublime-menu index 8aea68e8f..70312e37e 100644 --- a/Main.sublime-menu +++ b/Main.sublime-menu @@ -217,6 +217,16 @@ "caption": "LSP: Find References", "command": "lsp_symbol_references" }, + { + "caption": "Find References (in bottom panel)", + "command": "lsp_symbol_references", + "args": {"show_in": "bottom_panel"}, + }, + { + "caption": "Find References (in quick panel)", + "command": "lsp_symbol_references", + "args": {"show_in": "quick_panel"}, + }, { "caption": "LSP: Follow Link", "command": "lsp_open_link" @@ -255,20 +265,20 @@ "caption": "-" }, { - "caption": "Enable Language Server Globally…", - "command": "lsp_enable_language_server_globally", + "caption": "Enable Language Server Globally…", + "command": "lsp_enable_language_server_globally", }, { - "caption": "Disable Language Server Globally…", - "command": "lsp_disable_language_server_globally", + "caption": "Disable Language Server Globally…", + "command": "lsp_disable_language_server_globally", }, { - "caption": "Enable Language Server in Project…", - "command": "lsp_enable_language_server_in_project", + "caption": "Enable Language Server in Project…", + "command": "lsp_enable_language_server_in_project", }, { - "caption": "Disable Language Server in Project…", - "command": "lsp_disable_language_server_in_project", + "caption": "Disable Language Server in Project…", + "command": "lsp_disable_language_server_in_project", }, { "caption": "Troubleshoot Server Configuration…", diff --git a/docs/src/keyboard_shortcuts.md b/docs/src/keyboard_shortcuts.md index 41f0213ac..3b1e05a06 100644 --- a/docs/src/keyboard_shortcuts.md +++ b/docs/src/keyboard_shortcuts.md @@ -9,7 +9,7 @@ Refer to the [Customization section](customization.md#keyboard-shortcuts-key-bin | ------- | -------- | ------- | | Auto Complete | ctrl space (also on macOS) | `auto_complete` | Expand Selection | unbound | `lsp_expand_selection` -| Find References | shift f12 | `lsp_symbol_references` (supports optional args: `{"include_declaration": true/false}`) +| Find References | shift f12 | `lsp_symbol_references` (supports optional args: `{"include_declaration": true/false, "show_in": "bottom_panel"/"quick_panel"}`) | Fold | unbound | `lsp_fold` (supports optional args: `{"strict": true/false}` - to configure whether to fold only when the caret is contained within the folded region (`true`), or even when it is anywhere on the starting line (`false`)) | Fold All | unbound | `lsp_fold_all` (supports optional args: `{"kind": "comment" | "imports" | "region"}`) | Follow Link | unbound | `lsp_open_link` diff --git a/plugin/references.py b/plugin/references.py index df6073c79..c330451f4 100644 --- a/plugin/references.py +++ b/plugin/references.py @@ -7,7 +7,7 @@ from .core.sessions import Session from .core.settings import userprefs from .core.types import ClientConfig -from .core.typing import Dict, List, Optional, Tuple +from .core.typing import Dict, List, Literal, Optional, Tuple from .core.views import get_line from .core.views import get_symbol_kind_from_scope from .core.views import get_uri_and_position_from_location @@ -20,6 +20,9 @@ import sublime +ShowInArgument = Literal['bottom_panel', 'quick_panel'] + + class LspSymbolReferencesCommand(LspTextCommand): capability = 'referencesProvider' @@ -32,7 +35,8 @@ def is_enabled( force_group: bool = True, fallback: bool = False, group: int = -1, - include_declaration: bool = False + include_declaration: bool = False, + show_in: Optional[ShowInArgument] = None, ) -> bool: return fallback or super().is_enabled(event, point) @@ -44,10 +48,18 @@ def is_visible( force_group: bool = True, fallback: bool = False, group: int = -1, - include_declaration: bool = False + include_declaration: bool = False, + show_in: Optional[ShowInArgument] = None, ) -> bool: + # We include "in bottom panel" and "in quick panel" variants of `LSP: Find References` in the Command Palette + # but we only show the one that is not the same as the default one (per `show_references_in_quick_panel` + # setting). + if show_in == 'bottom_panel' and not userprefs().show_references_in_quick_panel or \ + show_in == 'quick_panel' and userprefs().show_references_in_quick_panel: + return False if self.applies_to_context_menu(event): - return self.is_enabled(event, point, side_by_side, fallback) + return self.is_enabled( + event, point, side_by_side, force_group, fallback, group, include_declaration, show_in) return True def run( @@ -59,7 +71,8 @@ def run( force_group: bool = True, fallback: bool = False, group: int = -1, - include_declaration: bool = False + include_declaration: bool = False, + show_in: Optional[ShowInArgument] = None, ) -> None: session = self.best_session(self.capability) file_path = self.view.file_name() @@ -85,6 +98,7 @@ def run( force_group, fallback, group, + show_in, word_range.begin() ) ) @@ -99,11 +113,12 @@ def _handle_response_async( force_group: bool, fallback: bool, group: int, + show_in: Optional[ShowInArgument], position: int, response: Optional[List[Location]] ) -> None: sublime.set_timeout(lambda: self._handle_response( - word, session, side_by_side, force_group, fallback, group, position, response)) + word, session, side_by_side, force_group, fallback, group, show_in, position, response)) def _handle_response( self, @@ -113,11 +128,12 @@ def _handle_response( force_group: bool, fallback: bool, group: int, + show_in: Optional[ShowInArgument], position: int, response: Optional[List[Location]] ) -> None: if response: - if userprefs().show_references_in_quick_panel: + if show_in == 'quick_panel' or (show_in is None and userprefs().show_references_in_quick_panel): self._show_references_in_quick_panel( word, session, response, side_by_side, force_group, group, position) else: From e9d4c349b75ea9948bb35bd028dcd1c96bbc6167 Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Sun, 28 Jan 2024 23:37:58 +0100 Subject: [PATCH 02/10] lint --- plugin/references.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/references.py b/plugin/references.py index c330451f4..0e32ea63e 100644 --- a/plugin/references.py +++ b/plugin/references.py @@ -55,7 +55,7 @@ def is_visible( # but we only show the one that is not the same as the default one (per `show_references_in_quick_panel` # setting). if show_in == 'bottom_panel' and not userprefs().show_references_in_quick_panel or \ - show_in == 'quick_panel' and userprefs().show_references_in_quick_panel: + show_in == 'quick_panel' and userprefs().show_references_in_quick_panel: return False if self.applies_to_context_menu(event): return self.is_enabled( From e6ed0393bb134cef8372fab10ffec4a774793f69 Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Mon, 29 Jan 2024 21:20:54 +0100 Subject: [PATCH 03/10] handle primary key in context menus --- Context.sublime-menu | 14 -------------- Main.sublime-menu | 10 ---------- docs/src/keyboard_shortcuts.md | 16 ++++++++-------- plugin/references.py | 22 ++++++++++++++-------- 4 files changed, 22 insertions(+), 40 deletions(-) diff --git a/Context.sublime-menu b/Context.sublime-menu index 925923fad..ba686b208 100644 --- a/Context.sublime-menu +++ b/Context.sublime-menu @@ -7,20 +7,6 @@ "command": "lsp_symbol_references", "caption": "Find References" }, - { - "command": "lsp_symbol_references", - "caption": "Find References (in bottom panel)", - "args": { - "show_in": "bottom_panel" - }, - }, - { - "command": "lsp_symbol_references", - "caption": "Find References (in quick panel)", - "args": { - "show_in": "quick_panel" - }, - }, { "command": "lsp_symbol_definition", "caption": "Goto Definition…" diff --git a/Main.sublime-menu b/Main.sublime-menu index 70312e37e..6eef29d01 100644 --- a/Main.sublime-menu +++ b/Main.sublime-menu @@ -217,16 +217,6 @@ "caption": "LSP: Find References", "command": "lsp_symbol_references" }, - { - "caption": "Find References (in bottom panel)", - "command": "lsp_symbol_references", - "args": {"show_in": "bottom_panel"}, - }, - { - "caption": "Find References (in quick panel)", - "command": "lsp_symbol_references", - "args": {"show_in": "quick_panel"}, - }, { "caption": "LSP: Follow Link", "command": "lsp_open_link" diff --git a/docs/src/keyboard_shortcuts.md b/docs/src/keyboard_shortcuts.md index 3b1e05a06..ebfe264a9 100644 --- a/docs/src/keyboard_shortcuts.md +++ b/docs/src/keyboard_shortcuts.md @@ -9,15 +9,15 @@ Refer to the [Customization section](customization.md#keyboard-shortcuts-key-bin | ------- | -------- | ------- | | Auto Complete | ctrl space (also on macOS) | `auto_complete` | Expand Selection | unbound | `lsp_expand_selection` -| Find References | shift f12 | `lsp_symbol_references` (supports optional args: `{"include_declaration": true/false, "show_in": "bottom_panel"/"quick_panel"}`) -| Fold | unbound | `lsp_fold` (supports optional args: `{"strict": true/false}` - to configure whether to fold only when the caret is contained within the folded region (`true`), or even when it is anywhere on the starting line (`false`)) -| Fold All | unbound | `lsp_fold_all` (supports optional args: `{"kind": "comment" | "imports" | "region"}`) +| Find References | shift f12 | `lsp_symbol_references`
Supports optional args: `{"include_declaration": true | false, "show_in": "bottom_panel" | "quick_panel"}`.
Triggering from context menus while holding ctrl opens in "side by side" mode. +| Fold | unbound | `lsp_fold` | Supports optional args: `{"strict": true/false}` - to configure whether to fold only when the caret is contained within the folded region (`true`), or even when it is anywhere on the starting line (`false`). +| Fold All | unbound | `lsp_fold_all`
Supports optional args: `{"kind": "comment" | "imports" | "region"}`. | Follow Link | unbound | `lsp_open_link` | Format File | unbound | `lsp_format_document` | Format Selection | unbound | `lsp_format_document_range` | Goto Declaration | unbound | `lsp_symbol_declaration` | Goto Definition | unbound
suggested: f12 | `lsp_symbol_definition` -| Goto Diagnostic | unbound
suggested: f8 | `lsp_goto_diagnostic` (with args: `{"uri": "$view_uri"}`) +| Goto Diagnostic | unbound
suggested: f8 | `lsp_goto_diagnostic`
With args: `{"uri": "$view_uri"}`. | Goto Diagnostic in Project | unbound
suggested: shift f8 | `lsp_goto_diagnostic` | Goto Implementation | unbound | `lsp_symbol_implementation` | Goto Symbol in Project | unbound
suggested: ctrl shift r | `lsp_workspace_symbols` @@ -31,12 +31,12 @@ Refer to the [Customization section](customization.md#keyboard-shortcuts-key-bin | Restart Server | unbound | `lsp_restart_server` | Run Code Action | unbound | `lsp_code_actions` | Run Code Lens | unbound | `lsp_code_lens` -| Run Refactor Action | unbound | `lsp_code_actions` (with args: `{"only_kinds": ["refactor"]}`) -| Run Source Action | unbound | `lsp_code_actions` (with args: `{"only_kinds": ["source"]}`) -| Save All | unbound | `lsp_save_all` (supports optional args `{"only_files": true}` - to ignore buffers which have no associated file on disk) +| Run Refactor Action | unbound | `lsp_code_actions`
With args: `{"only_kinds": ["refactor"]}`. +| Run Source Action | unbound | `lsp_code_actions`
With args: `{"only_kinds": ["source"]}`. +| Save All | unbound | `lsp_save_all`
Supports optional args `{"only_files": true}` - to ignore buffers which have no associated file on disk. | Show Call Hierarchy | unbound | `lsp_call_hierarchy` | Show Type Hierarchy | unbound | `lsp_type_hierarchy` | Signature Help | ctrl alt space | `lsp_signature_help_show` | Toggle Diagnostics Panel | ctrl alt m | `lsp_show_diagnostics_panel` -| Toggle Inlay Hints | unbound | `lsp_toggle_inlay_hints` (supports optional args: `{"enable": true/false}`) +| Toggle Inlay Hints | unbound | `lsp_toggle_inlay_hints`
Supports optional args: `{"enable": true/false}`. | Toggle Log Panel | unbound | `lsp_toggle_server_panel` diff --git a/plugin/references.py b/plugin/references.py index 0e32ea63e..0cc6e8d93 100644 --- a/plugin/references.py +++ b/plugin/references.py @@ -99,6 +99,7 @@ def run( fallback, group, show_in, + event, word_range.begin() ) ) @@ -114,11 +115,12 @@ def _handle_response_async( fallback: bool, group: int, show_in: Optional[ShowInArgument], + event: Optional[dict], position: int, response: Optional[List[Location]] ) -> None: sublime.set_timeout(lambda: self._handle_response( - word, session, side_by_side, force_group, fallback, group, show_in, position, response)) + word, session, side_by_side, force_group, fallback, group, show_in, event, position, response)) def _handle_response( self, @@ -129,17 +131,21 @@ def _handle_response( fallback: bool, group: int, show_in: Optional[ShowInArgument], + event: Optional[dict], position: int, response: Optional[List[Location]] ) -> None: - if response: - if show_in == 'quick_panel' or (show_in is None and userprefs().show_references_in_quick_panel): - self._show_references_in_quick_panel( - word, session, response, side_by_side, force_group, group, position) - else: - self._show_references_in_output_panel(word, session, response) - else: + if not response: self._handle_no_results(fallback, side_by_side) + return + modifier_keys = (event or {}).get('modifier_keys', {}) + show_in_quick_panel = show_in == 'quick_panel' or show_in is None and userprefs().show_references_in_quick_panel + if modifier_keys.get('primary') and show_in_quick_panel and side_by_side is False: + side_by_side = True + if show_in_quick_panel: + self._show_references_in_quick_panel(word, session, response, side_by_side, force_group, group, position) + else: + self._show_references_in_output_panel(word, session, response) def _handle_no_results(self, fallback: bool = False, side_by_side: bool = False) -> None: window = self.view.window() From 3a1a1973c451849b6b76c9f8bdae5513a4f87c4c Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Mon, 29 Jan 2024 21:23:19 +0100 Subject: [PATCH 04/10] formatting --- docs/src/keyboard_shortcuts.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/keyboard_shortcuts.md b/docs/src/keyboard_shortcuts.md index ebfe264a9..e866654c9 100644 --- a/docs/src/keyboard_shortcuts.md +++ b/docs/src/keyboard_shortcuts.md @@ -10,7 +10,7 @@ Refer to the [Customization section](customization.md#keyboard-shortcuts-key-bin | Auto Complete | ctrl space (also on macOS) | `auto_complete` | Expand Selection | unbound | `lsp_expand_selection` | Find References | shift f12 | `lsp_symbol_references`
Supports optional args: `{"include_declaration": true | false, "show_in": "bottom_panel" | "quick_panel"}`.
Triggering from context menus while holding ctrl opens in "side by side" mode. -| Fold | unbound | `lsp_fold` | Supports optional args: `{"strict": true/false}` - to configure whether to fold only when the caret is contained within the folded region (`true`), or even when it is anywhere on the starting line (`false`). +| Fold | unbound | `lsp_fold`
Supports optional args: `{"strict": true/false}` - to configure whether to fold only when the caret is contained within the folded region (`true`), or even when it is anywhere on the starting line (`false`). | Fold All | unbound | `lsp_fold_all`
Supports optional args: `{"kind": "comment" | "imports" | "region"}`. | Follow Link | unbound | `lsp_open_link` | Format File | unbound | `lsp_format_document` From 53844021fde85a7e613373818baf48dc4f8ba694 Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Mon, 29 Jan 2024 21:25:28 +0100 Subject: [PATCH 05/10] formattign --- plugin/references.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/references.py b/plugin/references.py index 0cc6e8d93..8a502eda3 100644 --- a/plugin/references.py +++ b/plugin/references.py @@ -140,9 +140,9 @@ def _handle_response( return modifier_keys = (event or {}).get('modifier_keys', {}) show_in_quick_panel = show_in == 'quick_panel' or show_in is None and userprefs().show_references_in_quick_panel - if modifier_keys.get('primary') and show_in_quick_panel and side_by_side is False: - side_by_side = True if show_in_quick_panel: + if modifier_keys.get('primary') and side_by_side is False: + side_by_side = True self._show_references_in_quick_panel(word, session, response, side_by_side, force_group, group, position) else: self._show_references_in_output_panel(word, session, response) From a4bad14cb583a3de4ce1d77224c6aee815f4999f Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Mon, 29 Jan 2024 21:28:44 +0100 Subject: [PATCH 06/10] handle shift --- docs/src/keyboard_shortcuts.md | 2 +- plugin/references.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/src/keyboard_shortcuts.md b/docs/src/keyboard_shortcuts.md index e866654c9..ec28848dd 100644 --- a/docs/src/keyboard_shortcuts.md +++ b/docs/src/keyboard_shortcuts.md @@ -9,7 +9,7 @@ Refer to the [Customization section](customization.md#keyboard-shortcuts-key-bin | ------- | -------- | ------- | | Auto Complete | ctrl space (also on macOS) | `auto_complete` | Expand Selection | unbound | `lsp_expand_selection` -| Find References | shift f12 | `lsp_symbol_references`
Supports optional args: `{"include_declaration": true | false, "show_in": "bottom_panel" | "quick_panel"}`.
Triggering from context menus while holding ctrl opens in "side by side" mode. +| Find References | shift f12 | `lsp_symbol_references`
Supports optional args: `{"include_declaration": true | false, "show_in": "bottom_panel" | "quick_panel"}`.
Triggering from context menus while holding ctrl opens in "side by side" mode. Holding shift triggers opposite behavior relative to what `show_references_in_quick_panel` is set to. | Fold | unbound | `lsp_fold`
Supports optional args: `{"strict": true/false}` - to configure whether to fold only when the caret is contained within the folded region (`true`), or even when it is anywhere on the starting line (`false`). | Fold All | unbound | `lsp_fold_all`
Supports optional args: `{"kind": "comment" | "imports" | "region"}`. | Follow Link | unbound | `lsp_open_link` diff --git a/plugin/references.py b/plugin/references.py index 8a502eda3..b9a21974b 100644 --- a/plugin/references.py +++ b/plugin/references.py @@ -140,6 +140,8 @@ def _handle_response( return modifier_keys = (event or {}).get('modifier_keys', {}) show_in_quick_panel = show_in == 'quick_panel' or show_in is None and userprefs().show_references_in_quick_panel + if modifier_keys.get('shift'): + show_in_quick_panel = not show_in_quick_panel if show_in_quick_panel: if modifier_keys.get('primary') and side_by_side is False: side_by_side = True From 5782f87ae31d33b168986c9d06b07e7619420da8 Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Wed, 31 Jan 2024 22:17:07 +0100 Subject: [PATCH 07/10] flip mode only if not explicitly specified --- plugin/references.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/plugin/references.py b/plugin/references.py index b9a21974b..368b0a380 100644 --- a/plugin/references.py +++ b/plugin/references.py @@ -139,11 +139,14 @@ def _handle_response( self._handle_no_results(fallback, side_by_side) return modifier_keys = (event or {}).get('modifier_keys', {}) - show_in_quick_panel = show_in == 'quick_panel' or show_in is None and userprefs().show_references_in_quick_panel - if modifier_keys.get('shift'): - show_in_quick_panel = not show_in_quick_panel + if show_in is None: + show_in_quick_panel = userprefs().show_references_in_quick_panel + if modifier_keys.get('shift'): + show_in_quick_panel = not show_in_quick_panel + else: + show_in_quick_panel = show_in == 'quick_panel' if show_in_quick_panel: - if modifier_keys.get('primary') and side_by_side is False: + if modifier_keys.get('primary'): side_by_side = True self._show_references_in_quick_panel(word, session, response, side_by_side, force_group, group, position) else: From 7d3e4653e3291341aa5431d643f27aa2858fd2c5 Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Wed, 31 Jan 2024 22:17:55 +0100 Subject: [PATCH 08/10] renames --- Default.sublime-commands | 6 +++--- LSP.sublime-settings | 2 +- docs/src/keyboard_shortcuts.md | 2 +- plugin/references.py | 8 ++++---- sublime-package.json | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Default.sublime-commands b/Default.sublime-commands index ee307c686..4bfcba5bc 100644 --- a/Default.sublime-commands +++ b/Default.sublime-commands @@ -122,14 +122,14 @@ "command": "lsp_symbol_references" }, { - "caption": "LSP: Find References (in bottom panel)", + "caption": "LSP: Find References (Bottom Panel)", "command": "lsp_symbol_references", "args": { - "show_in": "bottom_panel" + "show_in": "output_panel" }, }, { - "caption": "LSP: Find References (in quick panel)", + "caption": "LSP: Find References (Quick Panel)", "command": "lsp_symbol_references", "args": { "show_in": "quick_panel" diff --git a/LSP.sublime-settings b/LSP.sublime-settings index baf277228..74245e8ba 100644 --- a/LSP.sublime-settings +++ b/LSP.sublime-settings @@ -159,7 +159,7 @@ // --- Other -------------------------------------------------------------------------- - // Show symbol references in Sublime's quick panel instead of the bottom panel. + // Show symbol references in Sublime's quick panel instead of the output panel. "show_references_in_quick_panel": true, // Show code lens: diff --git a/docs/src/keyboard_shortcuts.md b/docs/src/keyboard_shortcuts.md index ec28848dd..8869c841e 100644 --- a/docs/src/keyboard_shortcuts.md +++ b/docs/src/keyboard_shortcuts.md @@ -9,7 +9,7 @@ Refer to the [Customization section](customization.md#keyboard-shortcuts-key-bin | ------- | -------- | ------- | | Auto Complete | ctrl space (also on macOS) | `auto_complete` | Expand Selection | unbound | `lsp_expand_selection` -| Find References | shift f12 | `lsp_symbol_references`
Supports optional args: `{"include_declaration": true | false, "show_in": "bottom_panel" | "quick_panel"}`.
Triggering from context menus while holding ctrl opens in "side by side" mode. Holding shift triggers opposite behavior relative to what `show_references_in_quick_panel` is set to. +| Find References | shift f12 | `lsp_symbol_references`
Supports optional args: `{"include_declaration": true | false, "show_in": "output_panel" | "quick_panel"}`.
Triggering from context menus while holding ctrl opens in "side by side" mode. Holding shift triggers opposite behavior relative to what `show_references_in_quick_panel` is set to. | Fold | unbound | `lsp_fold`
Supports optional args: `{"strict": true/false}` - to configure whether to fold only when the caret is contained within the folded region (`true`), or even when it is anywhere on the starting line (`false`). | Fold All | unbound | `lsp_fold_all`
Supports optional args: `{"kind": "comment" | "imports" | "region"}`. | Follow Link | unbound | `lsp_open_link` diff --git a/plugin/references.py b/plugin/references.py index 368b0a380..61b76b331 100644 --- a/plugin/references.py +++ b/plugin/references.py @@ -20,7 +20,7 @@ import sublime -ShowInArgument = Literal['bottom_panel', 'quick_panel'] +ShowInArgument = Literal['output_panel', 'quick_panel'] class LspSymbolReferencesCommand(LspTextCommand): @@ -51,10 +51,10 @@ def is_visible( include_declaration: bool = False, show_in: Optional[ShowInArgument] = None, ) -> bool: - # We include "in bottom panel" and "in quick panel" variants of `LSP: Find References` in the Command Palette - # but we only show the one that is not the same as the default one (per `show_references_in_quick_panel` + # We include "output panel" and "quick panel" variants of `LSP: Find References` in the Command Palette + # but we only show the one that is not the same as the default one (per the `show_references_in_quick_panel` # setting). - if show_in == 'bottom_panel' and not userprefs().show_references_in_quick_panel or \ + if show_in == 'output_panel' and not userprefs().show_references_in_quick_panel or \ show_in == 'quick_panel' and userprefs().show_references_in_quick_panel: return False if self.applies_to_context_menu(event): diff --git a/sublime-package.json b/sublime-package.json index 74689be68..5f84a65fa 100644 --- a/sublime-package.json +++ b/sublime-package.json @@ -656,7 +656,7 @@ "show_references_in_quick_panel": { "type": "boolean", "default": true, - "markdownDescription": "Show symbol references in Sublime's quick panel instead of the bottom panel." + "markdownDescription": "Show symbol references in Sublime's quick panel instead of the output panel." }, "popup_max_characters_width": { "type": "integer", From 0eaa563e622e9a071a66d6b6fb00d58b6af3fc37 Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Thu, 1 Feb 2024 20:13:01 +0100 Subject: [PATCH 09/10] update naming --- Default.sublime-commands | 6 +++--- docs/src/keyboard_shortcuts.md | 2 +- plugin/__init__.py | 2 ++ plugin/references.py | 26 +++++++++++++------------- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Default.sublime-commands b/Default.sublime-commands index 4bfcba5bc..75bb04d95 100644 --- a/Default.sublime-commands +++ b/Default.sublime-commands @@ -122,17 +122,17 @@ "command": "lsp_symbol_references" }, { - "caption": "LSP: Find References (Bottom Panel)", + "caption": "LSP: Find References (Output Panel)", "command": "lsp_symbol_references", "args": { - "show_in": "output_panel" + "output_mode": "output_panel" }, }, { "caption": "LSP: Find References (Quick Panel)", "command": "lsp_symbol_references", "args": { - "show_in": "quick_panel" + "output_mode": "quick_panel" }, }, { diff --git a/docs/src/keyboard_shortcuts.md b/docs/src/keyboard_shortcuts.md index 8869c841e..e277c542f 100644 --- a/docs/src/keyboard_shortcuts.md +++ b/docs/src/keyboard_shortcuts.md @@ -9,7 +9,7 @@ Refer to the [Customization section](customization.md#keyboard-shortcuts-key-bin | ------- | -------- | ------- | | Auto Complete | ctrl space (also on macOS) | `auto_complete` | Expand Selection | unbound | `lsp_expand_selection` -| Find References | shift f12 | `lsp_symbol_references`
Supports optional args: `{"include_declaration": true | false, "show_in": "output_panel" | "quick_panel"}`.
Triggering from context menus while holding ctrl opens in "side by side" mode. Holding shift triggers opposite behavior relative to what `show_references_in_quick_panel` is set to. +| Find References | shift f12 | `lsp_symbol_references`
Supports optional args: `{"include_declaration": true | false, "output_mode": "output_panel" | "quick_panel"}`.
Triggering from context menus while holding ctrl opens in "side by side" mode. Holding shift triggers opposite behavior relative to what `show_references_in_quick_panel` is set to. | Fold | unbound | `lsp_fold`
Supports optional args: `{"strict": true/false}` - to configure whether to fold only when the caret is contained within the folded region (`true`), or even when it is anywhere on the starting line (`false`). | Fold All | unbound | `lsp_fold_all`
Supports optional args: `{"kind": "comment" | "imports" | "region"}`. | Follow Link | unbound | `lsp_open_link` diff --git a/plugin/__init__.py b/plugin/__init__.py index 3f009dd68..17feaa4fc 100644 --- a/plugin/__init__.py +++ b/plugin/__init__.py @@ -12,6 +12,7 @@ from .core.registry import LspTextCommand from .core.registry import LspWindowCommand from .core.sessions import AbstractPlugin +from .core.sessions import AbstractPluginV2 from .core.sessions import register_plugin from .core.sessions import Session from .core.sessions import SessionBufferProtocol @@ -30,6 +31,7 @@ __all__ = [ '__version__', 'AbstractPlugin', + 'AbstractPluginV2', 'apply_text_edits', 'ClientConfig', 'css', diff --git a/plugin/references.py b/plugin/references.py index 61b76b331..03f106deb 100644 --- a/plugin/references.py +++ b/plugin/references.py @@ -20,7 +20,7 @@ import sublime -ShowInArgument = Literal['output_panel', 'quick_panel'] +OutputMode = Literal['output_panel', 'quick_panel'] class LspSymbolReferencesCommand(LspTextCommand): @@ -36,7 +36,7 @@ def is_enabled( fallback: bool = False, group: int = -1, include_declaration: bool = False, - show_in: Optional[ShowInArgument] = None, + output_mode: Optional[OutputMode] = None, ) -> bool: return fallback or super().is_enabled(event, point) @@ -49,17 +49,17 @@ def is_visible( fallback: bool = False, group: int = -1, include_declaration: bool = False, - show_in: Optional[ShowInArgument] = None, + output_mode: Optional[OutputMode] = None, ) -> bool: # We include "output panel" and "quick panel" variants of `LSP: Find References` in the Command Palette # but we only show the one that is not the same as the default one (per the `show_references_in_quick_panel` # setting). - if show_in == 'output_panel' and not userprefs().show_references_in_quick_panel or \ - show_in == 'quick_panel' and userprefs().show_references_in_quick_panel: + if output_mode == 'output_panel' and not userprefs().show_references_in_quick_panel or \ + output_mode == 'quick_panel' and userprefs().show_references_in_quick_panel: return False if self.applies_to_context_menu(event): return self.is_enabled( - event, point, side_by_side, force_group, fallback, group, include_declaration, show_in) + event, point, side_by_side, force_group, fallback, group, include_declaration, output_mode) return True def run( @@ -72,7 +72,7 @@ def run( fallback: bool = False, group: int = -1, include_declaration: bool = False, - show_in: Optional[ShowInArgument] = None, + output_mode: Optional[OutputMode] = None, ) -> None: session = self.best_session(self.capability) file_path = self.view.file_name() @@ -98,7 +98,7 @@ def run( force_group, fallback, group, - show_in, + output_mode, event, word_range.begin() ) @@ -114,13 +114,13 @@ def _handle_response_async( force_group: bool, fallback: bool, group: int, - show_in: Optional[ShowInArgument], + output_mode: Optional[OutputMode], event: Optional[dict], position: int, response: Optional[List[Location]] ) -> None: sublime.set_timeout(lambda: self._handle_response( - word, session, side_by_side, force_group, fallback, group, show_in, event, position, response)) + word, session, side_by_side, force_group, fallback, group, output_mode, event, position, response)) def _handle_response( self, @@ -130,7 +130,7 @@ def _handle_response( force_group: bool, fallback: bool, group: int, - show_in: Optional[ShowInArgument], + output_mode: Optional[OutputMode], event: Optional[dict], position: int, response: Optional[List[Location]] @@ -139,12 +139,12 @@ def _handle_response( self._handle_no_results(fallback, side_by_side) return modifier_keys = (event or {}).get('modifier_keys', {}) - if show_in is None: + if output_mode is None: show_in_quick_panel = userprefs().show_references_in_quick_panel if modifier_keys.get('shift'): show_in_quick_panel = not show_in_quick_panel else: - show_in_quick_panel = show_in == 'quick_panel' + show_in_quick_panel = output_mode == 'quick_panel' if show_in_quick_panel: if modifier_keys.get('primary'): side_by_side = True From e3d6a72c80ae5c03ba60ddd4020b98971b914b04 Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Fri, 2 Feb 2024 10:04:04 +0100 Subject: [PATCH 10/10] ops --- plugin/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugin/__init__.py b/plugin/__init__.py index 17feaa4fc..3f009dd68 100644 --- a/plugin/__init__.py +++ b/plugin/__init__.py @@ -12,7 +12,6 @@ from .core.registry import LspTextCommand from .core.registry import LspWindowCommand from .core.sessions import AbstractPlugin -from .core.sessions import AbstractPluginV2 from .core.sessions import register_plugin from .core.sessions import Session from .core.sessions import SessionBufferProtocol @@ -31,7 +30,6 @@ __all__ = [ '__version__', 'AbstractPlugin', - 'AbstractPluginV2', 'apply_text_edits', 'ClientConfig', 'css',