Sublime Forum

How to get argument in command from keybinding?

#1

Hello!

I have key binding:

{ “keys”: [“ctrl+space”], “command”: “auto_complete”, “args”: “Linux” }

And class which is called by ctrl+space

class Autocomplete(sublime_plugin.ViewEventListener):
    def on_query_completions(self, prefix, locations):

how to get argument “args”: “Linux” in method on_query_completions?

Aim is I need to know how on_query_completions was called, by key-press or by ctrl+space.

Thanks

0 Likes

#2

A ViewEventListener is not a command. It’s a passive object that does stuff reactively.

If you did have e.g. a TextCommand:

class FooCommand(sublime_plugin.TextCommand):
    def run(self, edit, volume):
        pass

The keybinding also needs to specify the name of the argument, not just its value:

{ "keys": ["ctrl+alt+up"], "command": "foo", "args": {"volume": 70} },
0 Likes