{
// this is the default key for `goto_definition`
"keys": ["super+alt+down"], "command": "goto_definition"
},
{
"keys": ["super+alt+down"], "command": "lsp_symbol_definition" ,
"context": [
{ "key": "lsp.is.active", "operator": "equal", "operand": true }
]
}
Update: @rwols pointed out that there is lsp_active to check, so this issue is now requesting a key for checking more specific capability.
I got my hand dirty and made this
import sublime_plugin
from LSP.plugin.core.registry import session_for_view
class LspCapability(sublime_plugin.EventListener):
def on_query_context(self, view, key, operator, operand, match_all):
if key == "lsp.client_with_capability":
return session_for_view(view, operand)
and now I could do
{
"keys": ["super+alt+down"], "command": "lsp_symbol_definition" ,
"context": [
{ "key": "lsp.client_with_capability", "operator": "equal", "operand": "definitionProvider" }
]
}
Any interest in getting this merged?
Pretty cool :-)
In a non lsp document, lsp_symbol_definition is disabled, hence f12 is simply malfunction. It only fallbacks to goto_definition when lsp is at work.
You are right... No wonder sometimes I get my F12 not working :open_mouth:
lsp_symbol_definition is not enabled hence not even be run in that case.
Related: https://github.com/tomv564/LSP/issues/651, https://github.com/tomv564/LSP/commit/88fc8f9786569aab2a09a62f873af7e46aaef025
I think this already works with lsp_active, no?
@rwols I can confirm that lsp_active works. Thanks.
{ "keys": ["f12"], "command": "lsp_symbol_definition", "context": [{"key": "setting.lsp_active"}]},
Maybe it is worth writing it in the docs :)
Though lsp_active is good enough for my purpose, the context key I posted above also checks if the client has such capability.
{ "keys": ["f12"], "command": "lsp_symbol_definition", "context": [{"key": "setting.lsp_active"}]},Maybe this is worth written in the docs :)
Perhaps, we should put the context in all these keyblindings
I changed the original post and the title for a key checking a more specific capability. (Though I am already happy wtih lsp_active) :)
Fixed by #1142 for ST4. Check out the new keybinding contexts.
Most helpful comment
Though
lsp_activeis good enough for my purpose, the context key I posted above also checks if the client has such capability.Perhaps, we should put the context in all these keyblindings