I have just started learning about plugins and I can find no information about what <args>
can be, which are mentioned here.
Could someone link a resource?
I have just started learning about plugins and I can find no information about what <args>
can be, which are mentioned here.
Could someone link a resource?
<args>
can be anything you want. For instance,
class FooCommand(sublime_plugin.TextCommand):
def run(self, edit):
# invoke in the console with
# view.run_command("foo")
print("FooCommand")
class BarCommand(sublime_plugin.TextCommand):
def run(self, edit, do_the_thing):
# invoke in the console with
# view.run_command("bar", {"do_the_thing": True})
print("BarCommand:", do_the_thing)
class BazCommand(sublime_plugin.TextCommand):
def run(self, edit, arg1, arg2):
# invoke in the console with
# view.run_command("baz", {"arg1": "Hello", "arg2": "World"})
print("BazCommand:", arg1, arg2)
class QuxCommand(sublime_plugin.TextCommand):
def run(self, edit, **kwargs):
# invoke with any named parameters, .e.g.
# view.run_command("qux", {"foo": 1, "bar": "bla", "baz": True})
print("QuxCommand:", kwargs)
That said, unfortunately there’s a JSON translation layer in-between calling a command and receiving the arguments in the command, so, you cannot pass around Python objects between commands, except when they’re JSON-(de)serializable.
Oh, I am sorry.
While looking through other plugins to learn from, I misread a function. All is clear now!