Last active
February 14, 2020 06:29
-
-
Save kitlangton/8b522ecbafe6ea3f9cba8e9d8554a9b1 to your computer and use it in GitHub Desktop.
Talon vim grammar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from talon import Context, actions | |
import webbrowser | |
ctx = Context("vim") | |
ctx.lists["self.commands"] = { | |
"change": "c", | |
"delete": "d", | |
"yank": "y", | |
"copy": "y", | |
"select": "v" | |
} | |
ctx.lists["self.positions"] = { | |
"in": "i", | |
"inside": "i", | |
"around": "a" | |
} | |
ctx.lists["self.text_objects"] = { | |
"word": "w", | |
"paragraph": "p", | |
"block": "b", | |
"string": "'", | |
"dubstring": '"', | |
"parens": '(', | |
"braces": '{', | |
"brackets": '[', | |
} | |
@ctx.capture(rule='{self.commands}') | |
def command(m): | |
return m.commands[0] | |
@ctx.capture(rule='{self.positions}') | |
def position(m): | |
return m.positions[0] | |
@ctx.capture(rule='{self.text_objects}') | |
def text_object(m): | |
return m.text_objects[0] | |
ctx.commands = { | |
"<self.command> <self.position> <self.text_object>": lambda m: actions.insert("".join(m._words)), | |
"change surround <self.text_object> <self.text_object>": lambda m: actions.insert("cs" + "".join(m.text_object_list)), | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment