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

Add argument "include_declaration" to "lsp_symbol_references" #2275

Merged
merged 3 commits into from
May 30, 2023
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
2 changes: 1 addition & 1 deletion Default.sublime-keymap
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
{
"keys": ["shift+f12"],
"command": "lsp_symbol_references",
"args": {"side_by_side": false, "force_group": true, "fallback": false, "group": -1},
"args": {"side_by_side": false, "force_group": true, "fallback": false, "group": -1, "include_declaration": false},
"context": [{"key": "lsp.session_with_capability", "operand": "referencesProvider"}]
},
// Find References (side-by-side)
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`
| Find References | <kbd>shift</kbd> <kbd>f12</kbd> | `lsp_symbol_references` (supports optional args: `{"include_declaration": true/false}`)
| Follow Link | unbound | `lsp_open_link`
| Format File | unbound | `lsp_format_document`
| Format Selection | unbound | `lsp_format_document_range`
Expand Down
13 changes: 9 additions & 4 deletions plugin/references.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def is_enabled(
side_by_side: bool = False,
force_group: bool = True,
fallback: bool = False,
group: int = -1
group: int = -1,
include_declaration: bool = False
) -> bool:
return fallback or super().is_enabled(event, point)

Expand All @@ -41,7 +42,8 @@ def is_visible(
side_by_side: bool = False,
force_group: bool = True,
fallback: bool = False,
group: int = -1
group: int = -1,
include_declaration: bool = False
) -> bool:
if self.applies_to_context_menu(event):
return self.is_enabled(event, point, side_by_side, fallback)
Expand All @@ -55,7 +57,8 @@ def run(
side_by_side: bool = False,
force_group: bool = True,
fallback: bool = False,
group: int = -1
group: int = -1,
include_declaration: bool = False
rchl marked this conversation as resolved.
Show resolved Hide resolved
) -> None:
session = self.best_session(self.capability)
file_path = self.view.file_name()
Expand All @@ -65,7 +68,9 @@ def run(
params = {
'textDocument': position_params['textDocument'],
'position': position_params['position'],
'context': {"includeDeclaration": False},
'context': {
"includeDeclaration": include_declaration,
},
}
request = Request("textDocument/references", params, self.view, progress=True)
word_range = self.view.word(pos)
Expand Down