-
Notifications
You must be signed in to change notification settings - Fork 185
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
Improve keyboard shortcuts documentation #1799
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,43 +66,6 @@ You can include special variables in the `command_args` array that will be autom | |
| `"$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) | | ||
| `"$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) | | ||
|
||
### Overriding keybindings | ||
|
||
LSP's keybindings can be edited from the `Preferences: LSP Keybindings` command from the command palette. | ||
There is a special context called `lsp.session_with_capability` that can check whether there is a language server active | ||
with the given [LSP capability](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#initialize). | ||
Refer to the `ServerCapabilities` structure in that link. | ||
The following example overrides `ctrl+r` to use LSP's symbol provider when we're in a javascript or typescript view: | ||
|
||
```js | ||
{ | ||
"command": "lsp_document_symbols", | ||
"keys": [ | ||
"ctrl+r" | ||
], | ||
"context": [ | ||
{ | ||
"key": "lsp.session_with_capability", | ||
"operator": "equal", | ||
"operand": "documentSymbolProvider" | ||
}, | ||
{ | ||
"key": "selector", | ||
"operator": "equal", | ||
"operand": "source.ts, source.js" | ||
} | ||
] | ||
}, | ||
``` | ||
|
||
More useful keybindings (OS-X), edit Package Settings -> LSP -> Key Bindings | ||
```js | ||
{ "keys": ["f2"], "command": "lsp_symbol_rename" }, | ||
{ "keys": ["f12"], "command": "lsp_symbol_definition" }, | ||
{ "keys": ["super+option+r"], "command": "lsp_document_symbols" }, | ||
{ "keys": ["super+option+h"], "command": "lsp_hover"} | ||
``` | ||
Comment on lines
-98
to
-104
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've removed that part completely since those examples are bad as they don't check the context. And there are better versions of those in the default key bindings. |
||
|
||
### Show autocomplete documentation | ||
|
||
Some completion items can have documentation associated with them. | ||
|
@@ -111,47 +74,3 @@ Some completion items can have documentation associated with them. | |
|
||
To show the documentation popup you can click the **More** link in the bottom of the autocomplete, | ||
or you can use the default sublime keybinding <kbd>F12</kbd> to trigger it. | ||
|
||
You can change the default keybinding by remapping the command as below: | ||
|
||
```js | ||
{ | ||
"command": "auto_complete_open_link", | ||
"keys": ["f12"], | ||
"context": [ | ||
{ | ||
"key": "auto_complete_visible", | ||
"operator": "equal", | ||
"operand": true | ||
} | ||
] | ||
}, | ||
``` | ||
Note that <kbd>F12</kbd> may conflict with your Goto Definition keybinding. To avoid the conflict, make sure that you | ||
have a context which checks that the AC widget is not visible: | ||
```js | ||
{ | ||
"command": "lsp_symbol_definition", | ||
"keys": [ | ||
"f12" | ||
], | ||
"context": [ | ||
{ | ||
"key": "lsp.session_with_capability", | ||
"operator": "equal", | ||
"operand": "definitionProvider" | ||
}, | ||
{ | ||
"key": "auto_complete_visible", | ||
"operator": "equal", | ||
"operand": false | ||
} | ||
] | ||
}, | ||
``` | ||
There is an example of this in LSP's default keybindings. | ||
Comment on lines
-130
to
-152
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This part was in a very weird place, talking about F12 potentially conflicting with default binding after the example that shown how to override default F12 key binding without conflicting with "goto definition". I've deemed that part completely unnecessary and it was removed. |
||
|
||
### Mouse map configuration | ||
|
||
See below link, but bind to `lsp_symbol_definition` command | ||
https://stackoverflow.com/questions/16235706/sublime-3-set-key-map-for-function-goto-definition |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll paste here the new text since it's not clear from the diff how this has changed.
Basically made the first paragraph talk about default (disabled) key bindings and how to enable them.
The second paragraph is the more advanced part about customizing key bindings (which I imagine most won't need as the provided default ones should be enough).