Skip to content

Commit

Permalink
update naming
Browse files Browse the repository at this point in the history
  • Loading branch information
rchl committed Feb 1, 2024
1 parent 7d3e465 commit 0eaa563
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
6 changes: 3 additions & 3 deletions Default.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/src/keyboard_shortcuts.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Refer to the [Customization section](customization.md#keyboard-shortcuts-key-bin
| ------- | -------- | ------- |
| Auto Complete | <kbd>ctrl</kbd> <kbd>space</kbd> (also on macOS) | `auto_complete`
| Expand Selection | unbound | `lsp_expand_selection`
| Find References | <kbd>shift</kbd> <kbd>f12</kbd> | `lsp_symbol_references`<br>Supports optional args: `{"include_declaration": true | false, "show_in": "output_panel" | "quick_panel"}`.<br>Triggering from context menus while holding <kbd>ctrl</kbd> opens in "side by side" mode. Holding <kbd>shift</kbd> triggers opposite behavior relative to what `show_references_in_quick_panel` is set to.
| Find References | <kbd>shift</kbd> <kbd>f12</kbd> | `lsp_symbol_references`<br>Supports optional args: `{"include_declaration": true | false, "output_mode": "output_panel" | "quick_panel"}`.<br>Triggering from context menus while holding <kbd>ctrl</kbd> opens in "side by side" mode. Holding <kbd>shift</kbd> triggers opposite behavior relative to what `show_references_in_quick_panel` is set to.
| Fold | unbound | `lsp_fold`<br>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`<br>Supports optional args: `{"kind": "comment" | "imports" | "region"}`.
| Follow Link | unbound | `lsp_open_link`
Expand Down
2 changes: 2 additions & 0 deletions plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,6 +31,7 @@
__all__ = [
'__version__',
'AbstractPlugin',
'AbstractPluginV2',
'apply_text_edits',
'ClientConfig',
'css',
Expand Down
26 changes: 13 additions & 13 deletions plugin/references.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import sublime


ShowInArgument = Literal['output_panel', 'quick_panel']
OutputMode = Literal['output_panel', 'quick_panel']


class LspSymbolReferencesCommand(LspTextCommand):
Expand All @@ -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)

Expand All @@ -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(
Expand All @@ -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()
Expand All @@ -98,7 +98,7 @@ def run(
force_group,
fallback,
group,
show_in,
output_mode,
event,
word_range.begin()
)
Expand All @@ -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,
Expand All @@ -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]]
Expand All @@ -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
Expand Down

0 comments on commit 0eaa563

Please sign in to comment.