Skip to content

Commit

Permalink
Add argument "include_declaration" to "lsp_symbol_references" (#2275)
Browse files Browse the repository at this point in the history
  • Loading branch information
EmasXP authored May 30, 2023
1 parent 9ec8001 commit 53c75bf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
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
) -> 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

0 comments on commit 53c75bf

Please sign in to comment.