Closed JGJP closed 8 months ago
I tried this kind of keybinding, but it doesn't seem to work:
{
"keys": ["ctrl+super+m"],
"command": "lsp_typescript_code_action",
"args": {
"action": "source.addMissingImports.ts"
}
}
You could create a keybindings like this:
// Show Source Actions
{
"command": "lsp_code_actions",
"args": {
"only_kinds": [
"source"
]
},
"keys": [
"UNBOUND"
],
"context": [
{
"key": "lsp.session_with_capability",
"operator": "equal",
"operand": "codeActionProvider.codeActionKinds"
}
]
},
That will list all available source code actions in a quick panel and you can select the one you need.
If you need a keybinding for specifically one code action, that is currently not possible, For that there is this open issue https://github.com/sublimelsp/LSP/issues/1356
Also the lsp_code_actions
command is also accessible via the context menu(the right click menu) LSP > Source Action...
.
With this configuration in LSP, I can have LSP-typescript do a bunch of useful stuff when saving the file:
Is there any way to do the this same stuff without having to save the file? For example with a command or keyboard shortcut, that would execute the actions file-wide instead of per warning/error like the current code actions context menu does.