Skip to content

Instantly share code, notes, and snippets.

@tshort
Created June 26, 2020 10:49
Show Gist options
  • Save tshort/7dc4457e01935e917536f32eb104a16d to your computer and use it in GitHub Desktop.
Save tshort/7dc4457e01935e917536f32eb104a16d to your computer and use it in GitHub Desktop.
Implementing the mirror plugin for Kakoune in Dance
[
{
"key": "'",
"command": "dance.openMenu",
"args": {
"menu": "mirror"
},
"when": "editorTextFocus && dance.mode == 'normal'"
},
]
"multiCommand.commands": [
{
"command": "multiCommand.mirror.c",
"sequence": [
"dance.select.copy",
"dance.selections.flip",
"dance.select.copy.backwards",
"dance.selections.flip",
]
},
{
"command": "multiCommand.mirror.h",
"sequence": [
"dance.left.extend",
"dance.selections.flip",
"dance.right.extend",
"dance.selections.flip",
]
},
{
"command": "multiCommand.mirror.l",
"sequence": [
"dance.right.extend",
"dance.selections.flip",
"dance.left.extend",
"dance.selections.flip",
]
},
{
"command": "multiCommand.mirror.j",
"sequence": [
"dance.down.extend",
"dance.selections.flip",
"dance.up.extend",
"dance.selections.flip",
]
},
{
"command": "multiCommand.mirror.k",
"sequence": [
"dance.up.extend",
"dance.selections.flip",
"dance.down.extend",
"dance.selections.flip",
]
},
{
"command": "multiCommand.mirror.J",
"sequence": [
"dance.down.extend",
"dance.selections.flip",
"dance.up.extend",
"dance.selections.flip",
"dance.expandLines",
]
},
{
"command": "multiCommand.mirror.K",
"sequence": [
"dance.up.extend",
"dance.selections.flip",
"dance.down.extend",
"dance.selections.flip",
"dance.expandLines",
]
},
{
"command": "multiCommand.mirror.b",
"sequence": [
"dance.select.word.previous.extend",
"dance.selections.flip",
"dance.select.word.extend",
"dance.selections.flip",
]
},
{
"command": "multiCommand.mirror.w",
"sequence": [
"dance.select.word.extend",
"dance.selections.flip",
"dance.select.word.previous.extend",
"dance.selections.flip",
]
},
{
"command": "multiCommand.mirror.e",
"sequence": [
"dance.select.word.end.extend",
"dance.selections.flip",
"dance.select.word.previous.extend",
"dance.selections.flip",
]
},
{
"command": "multiCommand.mirror.p",
"sequence": [
{"command": "dance.objects.performSelection", "args": {"object": "paragraph", "action": "selectToEnd", "extend": true, "inner": false}},
"dance.selections.flip",
{"command": "dance.objects.performSelection", "args": {"object": "paragraph", "action": "selectToStart", "extend": true, "inner": false}},
"dance.selections.flip",
]
},
{
"command": "multiCommand.mirror.s",
"sequence": [
{"command": "dance.objects.performSelection", "args": {"object": "sentence", "action": "selectToEnd", "extend": true, "inner": false}},
"dance.selections.flip",
{"command": "dance.objects.performSelection", "args": {"object": "sentence", "action": "selectToStart", "extend": true, "inner": false}},
"dance.selections.flip",
]
},
{
"command": "multiCommand.mirror.m",
"sequence": [
"dance.select.enclosing.extend",
"dance.selections.flip",
"dance.select.enclosing.extend.backwards",
"dance.selections.flip",
]
},
{
"command": "multiCommand.mirror.lparen",
"sequence": [
"dance.insert.after",
{"command": "type", "args": {"text": ")"}}
"dance.set.normal",
"dance.marks.saveSelections", // shouldn't need this
"dance.insert.before",
{"command": "type", "args": {"text": "("}}
"dance.set.normal",
"dance.marks.restoreSelections",
"dance.selections.flip",
"dance.left.extend",
]
},
{
"command": "multiCommand.mirror.lcurly",
"sequence": [
"dance.insert.after",
{"command": "type", "args": {"text": "}"}}
"dance.set.normal",
"dance.marks.saveSelections", // shouldn't need this
"dance.insert.before",
{"command": "type", "args": {"text": "{"}}
"dance.set.normal",
"dance.marks.restoreSelections",
"dance.selections.flip",
"dance.left.extend",
]
},
{
"command": "multiCommand.mirror.lbracket",
"sequence": [
"dance.insert.after",
{"command": "type", "args": {"text": "]"}}
"dance.set.normal",
"dance.marks.saveSelections", // shouldn't need this
"dance.insert.before",
{"command": "type", "args": {"text": "["}}
"dance.set.normal",
"dance.marks.restoreSelections",
"dance.selections.flip",
"dance.left.extend",
]
},
{
"command": "multiCommand.mirror.lt",
"sequence": [
"dance.insert.after",
{"command": "type", "args": {"text": ">"}}
"dance.set.normal",
"dance.marks.saveSelections", // shouldn't need this
"dance.insert.before",
{"command": "type", "args": {"text": "<"}}
"dance.set.normal",
"dance.marks.restoreSelections",
"dance.selections.flip",
"dance.left.extend",
]
},
{
"command": "multiCommand.mirror.rparen",
"sequence": [
"dance.insert.after",
{"command": "type", "args": {"text": " )"}}
"dance.set.normal",
"dance.marks.saveSelections", // shouldn't need this
"dance.insert.before",
{"command": "type", "args": {"text": "( "}}
"dance.set.normal",
"dance.marks.restoreSelections",
"dance.selections.flip",
"dance.left.extend",
"dance.left.extend",
]
},
{
"command": "multiCommand.mirror.rcurly",
"sequence": [
"dance.insert.after",
{"command": "type", "args": {"text": " }"}}
"dance.set.normal",
"dance.marks.saveSelections", // shouldn't need this
"dance.insert.before",
{"command": "type", "args": {"text": "{ "}}
"dance.set.normal",
"dance.marks.restoreSelections",
"dance.selections.flip",
"dance.left.extend",
"dance.left.extend",
]
},
{
"command": "multiCommand.mirror.rbracket",
"sequence": [
"dance.insert.after",
{"command": "type", "args": {"text": " ]"}}
"dance.set.normal",
"dance.marks.saveSelections", // shouldn't need this
"dance.insert.before",
{"command": "type", "args": {"text": "[ "}}
"dance.set.normal",
"dance.marks.restoreSelections",
"dance.selections.flip",
"dance.left.extend",
"dance.left.extend",
]
},
{
"command": "multiCommand.mirror.gt",
"sequence": [
"dance.insert.after",
{"command": "type", "args": {"text": " >"}}
"dance.set.normal",
"dance.marks.saveSelections", // shouldn't need this
"dance.insert.before",
{"command": "type", "args": {"text": "< "}}
"dance.set.normal",
"dance.marks.restoreSelections",
"dance.selections.flip",
"dance.left.extend",
"dance.left.extend",
]
},
{
"command": "multiCommand.mirror.doublequote",
"sequence": [
"dance.insert.after",
{"command": "type", "args": {"text": "\""}}
"dance.set.normal",
"dance.marks.saveSelections", // shouldn't need this
"dance.insert.before",
{"command": "type", "args": {"text": "\""}}
"dance.set.normal",
"dance.marks.restoreSelections",
"dance.selections.flip",
"dance.left.extend",
]
},
{
"command": "multiCommand.mirror.singlequote",
"sequence": [
"dance.insert.after",
{"command": "type", "args": {"text": "'"}}
"dance.set.normal",
"dance.marks.saveSelections", // shouldn't need this
"dance.insert.before",
{"command": "type", "args": {"text": "'"}}
"dance.set.normal",
"dance.marks.restoreSelections",
"dance.selections.flip",
"dance.left.extend",
]
},
{
"command": "multiCommand.mirror.backtick",
"sequence": [
"dance.insert.after",
{"command": "type", "args": {"text": "`"}}
"dance.set.normal",
"dance.marks.saveSelections", // shouldn't need this
"dance.insert.before",
{"command": "type", "args": {"text": "`"}}
"dance.set.normal",
"dance.marks.restoreSelections",
"dance.selections.flip",
"dance.left.extend",
]
},
{
"command": "multiCommand.mirror.d",
"sequence": [
"dance.marks.saveSelections",
"dance.select.firstLast",
"dance.delete.noYank",
"dance.marks.restoreSelections",
"dance.selections.forward",
]
},
],
"dance.menus": {
"mirror": {
"items": {
"c": {
"text": "column",
"command": "multiCommand.mirror.c",
},
"l": {
"text": "character left",
"command": "multiCommand.mirror.l",
},
"h": {
"text": "character right",
"command": "multiCommand.mirror.h",
},
"j": {
"text": "line down",
"command": "multiCommand.mirror.j",
},
"k": {
"text": "line up",
"command": "multiCommand.mirror.k",
},
"J": {
"text": "full line down",
"command": "multiCommand.mirror.J",
},
"K": {
"text": "full line up",
"command": "multiCommand.mirror.K",
},
"b": {
"text": "word begin",
"command": "multiCommand.mirror.b",
},
"w": {
"text": "word begin",
"command": "multiCommand.mirror.w",
},
"e": {
"text": "word end",
"command": "multiCommand.mirror.e",
},
"p": {
"text": "paragraph",
"command": "multiCommand.mirror.p",
},
"s": {
"text": "sentence",
"command": "multiCommand.mirror.s",
},
"m": {
"text": "matching",
"command": "multiCommand.mirror.m",
},
"(": {
"text": "(surround)",
"command": "multiCommand.mirror.lparen",
},
"{": {
"text": "{surround}",
"command": "multiCommand.mirror.lcurly",
},
"[": {
"text": "[surround]",
"command": "multiCommand.mirror.lbracket",
},
"<": {
"text": "<surround>",
"command": "multiCommand.mirror.lt",
},
")": {
"text": "( surround )",
"command": "multiCommand.mirror.rparen",
},
"}": {
"text": "{ surround }",
"command": "multiCommand.mirror.rcurly",
},
"]": {
"text": "[ surround ]",
"command": "multiCommand.mirror.rbracket",
},
">": {
"text": "< surround >",
"command": "multiCommand.mirror.gt",
},
"\"": {
"text": "\"surround\"",
"command": "multiCommand.mirror.doublequote",
},
"'": {
"text": "'surround'",
"command": "multiCommand.mirror.singlequote",
},
"`": {
"text": "`surround`",
"command": "multiCommand.mirror.backtick",
},
"d": {
"text": "delete surround",
"command": "multiCommand.mirror.d",
},
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment