defCommand don't require prefix on id

This commit is contained in:
2023-03-18 12:22:15 -06:00
parent de945dd93f
commit 55b425de98
5 changed files with 135 additions and 62 deletions

View File

@@ -167,11 +167,10 @@
// Example:
/*
(defCommand myExt.customCommand "Custom command that does something" "C-; C-c" [<args...>] <body...>)
(defCommand customCommand "Custom command that does something" "C-; C-c" [<args...>] <body...>)
*/
(defMacroVar extensionName "Kiss-Vscode")
(defMacro defCommand [context id description shortcut argList &body body]
(let [id (symbolNameValue id)
(let [functionName id
description (eval description)
shortcut (eval shortcut)
shortcutWithHyphensProcessed
@@ -188,12 +187,14 @@
"++" "-+")
packageJson
(Json.parse (File.getContent "package.json"))
extensionName
packageJson.name
keybindings
packageJson.contributes.keybindings
commands
packageJson.contributes.commands
functionName
(symbol (StringTools.replace id "." "_"))
id
"${extensionName}.${id}"
&mut keyBindingIndex null
&mut commandIndex null]
(doFor [idx binding] (enumerate keybindings)

View File

@@ -35,78 +35,150 @@
],
"keybindings": [
{
"command": "kiss.evalAndPrint",
"mac": "Cmd+; Cmd+e",
"key": "Ctrl+; Ctrl+e"
},
{
"command": "kiss.newKissClass",
"mac": "Cmd+; Cmd+c",
"key": "Ctrl+; Ctrl+c"
},
{
"command": "kiss.showCorrespondingFile",
"mac": "Cmd+; Cmd+f",
"key": "Ctrl+; Ctrl+f"
},
{
"command": "kiss.insertUTestCase",
"mac": "Cmd+; Cmd+t Cmd+c",
"key": "Ctrl+; Ctrl+t Ctrl+c"
},
{
"command": "kiss.mapLinesSync",
"mac": "Cmd+; Cmd+l Cmd+m",
"key": "Ctrl+; Ctrl+l Ctrl+m"
},
{
"command": "kiss.sortLinesSync",
"mac": "Cmd+; Cmd+l Cmd+s",
"key": "Ctrl+; Ctrl+l Ctrl+s"
},
{
"command": "kiss.updateExtension",
"command": "kiss-vscode.updateExtension",
"mac": "Cmd+; Cmd+u",
"key": "Ctrl+; Ctrl+u"
},
{
"command": "kiss.testAndUpdateExtension",
"command": "kiss-vscode.testAndUpdateExtension",
"mac": "Cmd+; Cmd+t Cmd+u",
"key": "Ctrl+; Ctrl+t Ctrl+u"
},
{
"command": "kiss-vscode.evalAndPrint",
"mac": "Cmd+; Cmd+e",
"key": "Ctrl+; Ctrl+e"
},
{
"command": "kiss-vscode.newKissClass",
"mac": "Cmd+; Cmd+c",
"key": "Ctrl+; Ctrl+c"
},
{
"command": "kiss-vscode.showCorrespondingFile",
"mac": "Cmd+; Cmd+f",
"key": "Ctrl+; Ctrl+f"
},
{
"command": "kiss-vscode.insertUTestCase",
"mac": "Cmd+; Cmd+t Cmd+c",
"key": "Ctrl+; Ctrl+t Ctrl+c"
},
{
"command": "kiss-vscode.mapLinesSync",
"mac": "Cmd+; Cmd+l Cmd+m",
"key": "Ctrl+; Ctrl+l Ctrl+m"
},
{
"command": "kiss-vscode.sortLinesSync",
"mac": "Cmd+; Cmd+l Cmd+s",
"key": "Ctrl+; Ctrl+l Ctrl+s"
},
{
"command": "kiss-vscode.{pos: {column: 21, line: 17, absoluteChar: 470, file: src/commands/ExtensionTools.kiss}, def: Symbol(updateExtension)}",
"mac": "Cmd+; Cmd+u",
"key": "Ctrl+; Ctrl+u"
},
{
"command": "kiss-vscode.{pos: {column: 21, line: 31, absoluteChar: 1216, file: src/commands/ExtensionTools.kiss}, def: Symbol(testAndUpdateExtension)}",
"mac": "Cmd+; Cmd+t Cmd+u",
"key": "Ctrl+; Ctrl+t Ctrl+u"
},
{
"command": "kiss-vscode.{pos: {column: 21, line: 1, absoluteChar: 20, file: src/commands/KissTools.kiss}, def: Symbol(evalAndPrint)}",
"mac": "Cmd+; Cmd+e",
"key": "Ctrl+; Ctrl+e"
},
{
"command": "kiss-vscode.{pos: {column: 21, line: 6, absoluteChar: 288, file: src/commands/KissTools.kiss}, def: Symbol(newKissClass)}",
"mac": "Cmd+; Cmd+c",
"key": "Ctrl+; Ctrl+c"
},
{
"command": "kiss-vscode.{pos: {column: 21, line: 55, absoluteChar: 2420, file: src/commands/KissTools.kiss}, def: Symbol(showCorrespondingFile)}",
"mac": "Cmd+; Cmd+f",
"key": "Ctrl+; Ctrl+f"
},
{
"command": "kiss-vscode.{pos: {column: 21, line: 58, absoluteChar: 2620, file: src/commands/KissTools.kiss}, def: Symbol(insertUTestCase)}",
"mac": "Cmd+; Cmd+t Cmd+c",
"key": "Ctrl+; Ctrl+t Ctrl+c"
},
{
"command": "kiss-vscode.{pos: {column: 21, line: 18, absoluteChar: 786, file: src/commands/Lines.kiss}, def: Symbol(mapLinesSync)}",
"mac": "Cmd+; Cmd+l Cmd+m",
"key": "Ctrl+; Ctrl+l Ctrl+m"
},
{
"command": "kiss-vscode.{pos: {column: 21, line: 33, absoluteChar: 1609, file: src/commands/Lines.kiss}, def: Symbol(sortLinesSync)}",
"mac": "Cmd+; Cmd+l Cmd+s",
"key": "Ctrl+; Ctrl+l Ctrl+s"
}
],
"commands": [
{
"title": "Kiss-Vscode: Evaluate and print a kiss expression's value",
"command": "kiss.evalAndPrint"
"title": "kiss-vscode: Update and reinstall the Kiss-Vscode extension you are editing",
"command": "kiss-vscode.updateExtension"
},
{
"title": "Kiss-Vscode: Create a new kiss class",
"command": "kiss.newKissClass"
"title": "kiss-vscode: Check test.sh, then update and reinstall the kiss-vscode extension you are editing",
"command": "kiss-vscode.testAndUpdateExtension"
},
{
"title": "Kiss-Vscode: Open the corresponding .kiss/.hx file to this one",
"command": "kiss.showCorrespondingFile"
"title": "kiss-vscode: Evaluate and print a kiss expression's value",
"command": "kiss-vscode.evalAndPrint"
},
{
"title": "Kiss-Vscode: Generate a UTest test case in this .hx/.kiss file",
"command": "kiss.insertUTestCase"
"title": "kiss-vscode: Create a new kiss class",
"command": "kiss-vscode.newKissClass"
},
{
"title": "Kiss-Vscode: Transform the selected text lines using a String->String kiss function",
"command": "kiss.mapLinesSync"
"title": "kiss-vscode: Open the corresponding .kiss/.hx file to this one",
"command": "kiss-vscode.showCorrespondingFile"
},
{
"title": "Kiss-Vscode: Sort the selected text lines using a (String,String)->Int comparator function",
"command": "kiss.sortLinesSync"
"title": "kiss-vscode: Generate a UTest test case in this .hx/.kiss file",
"command": "kiss-vscode.insertUTestCase"
},
{
"title": "Kiss-Vscode: Update and reinstall the Kiss-Vscode extension you are editing",
"command": "kiss.updateExtension"
"title": "kiss-vscode: Transform the selected text lines using a String->String kiss function",
"command": "kiss-vscode.mapLinesSync"
},
{
"title": "Kiss-Vscode: Check test.sh, then update and reinstall the kiss-vscode extension you are editing",
"command": "kiss.testAndUpdateExtension"
"title": "kiss-vscode: Sort the selected text lines using a (String,String)->Int comparator function",
"command": "kiss-vscode.sortLinesSync"
},
{
"title": "kiss-vscode: Update and reinstall the Kiss-Vscode extension you are editing",
"command": "kiss-vscode.{pos: {column: 21, line: 17, absoluteChar: 470, file: src/commands/ExtensionTools.kiss}, def: Symbol(updateExtension)}"
},
{
"title": "kiss-vscode: Check test.sh, then update and reinstall the kiss-vscode extension you are editing",
"command": "kiss-vscode.{pos: {column: 21, line: 31, absoluteChar: 1216, file: src/commands/ExtensionTools.kiss}, def: Symbol(testAndUpdateExtension)}"
},
{
"title": "kiss-vscode: Evaluate and print a kiss expression's value",
"command": "kiss-vscode.{pos: {column: 21, line: 1, absoluteChar: 20, file: src/commands/KissTools.kiss}, def: Symbol(evalAndPrint)}"
},
{
"title": "kiss-vscode: Create a new kiss class",
"command": "kiss-vscode.{pos: {column: 21, line: 6, absoluteChar: 288, file: src/commands/KissTools.kiss}, def: Symbol(newKissClass)}"
},
{
"title": "kiss-vscode: Open the corresponding .kiss/.hx file to this one",
"command": "kiss-vscode.{pos: {column: 21, line: 55, absoluteChar: 2420, file: src/commands/KissTools.kiss}, def: Symbol(showCorrespondingFile)}"
},
{
"title": "kiss-vscode: Generate a UTest test case in this .hx/.kiss file",
"command": "kiss-vscode.{pos: {column: 21, line: 58, absoluteChar: 2620, file: src/commands/KissTools.kiss}, def: Symbol(insertUTestCase)}"
},
{
"title": "kiss-vscode: Transform the selected text lines using a String->String kiss function",
"command": "kiss-vscode.{pos: {column: 21, line: 18, absoluteChar: 786, file: src/commands/Lines.kiss}, def: Symbol(mapLinesSync)}"
},
{
"title": "kiss-vscode: Sort the selected text lines using a (String,String)->Int comparator function",
"command": "kiss-vscode.{pos: {column: 21, line: 33, absoluteChar: 1609, file: src/commands/Lines.kiss}, def: Symbol(sortLinesSync)}"
}
],
"languages": [

View File

@@ -14,7 +14,7 @@
(return)
})
(defCommand context kiss.updateExtension "Update and reinstall the Kiss-Vscode extension you are editing" "C-; C-u" []
(defCommand context updateExtension "Update and reinstall the Kiss-Vscode extension you are editing" "C-; C-u" []
(if (= "Windows" (Sys.systemName))
(trySpawnSync "cmd.exe" ["/c" "npm" "install"] (options) forceUpdateFailure)
(trySpawnSync "npm" ["install"] (options) forceUpdateFailure))
@@ -28,6 +28,6 @@
{}
null)
(defCommand context kiss.testAndUpdateExtension "Check test.sh, then update and reinstall the kiss-vscode extension you are editing" "C-; C-t C-u" []
(defCommand context testAndUpdateExtension "Check test.sh, then update and reinstall the kiss-vscode extension you are editing" "C-; C-t C-u" []
(trySpawnSync "test.sh" [] (options) handleUpdateFailure)
(kiss_updateExtension))
(updateExtension))

View File

@@ -1,9 +1,9 @@
(defCommand context kiss.evalAndPrint "Evaluate and print a kiss expression's value" "C-; C-e" []
(defCommand context evalAndPrint "Evaluate and print a kiss expression's value" "C-; C-e" []
(let [st (selectedText)]
(withValueOrInputEditor st "kiss.evalAndPrint" "A kiss expression to evaluate"
(infoMessage (Std.string (evalString st))))))
(defCommand context kiss.newKissClass "Create a new kiss class" "C-; C-c" []
(defCommand context newKissClass "Create a new kiss class" "C-; C-c" []
(awaitLet [className (inputBox)]
(when className
(let [currentFile
@@ -52,10 +52,10 @@ class ${className} {}
(otherwise (throw "No corresponding file for ${kissOrHxFile}")))]
"${base}.${correspondingExt}"))
(defCommand context kiss.showCorrespondingFile "Open the corresponding .kiss/.hx file to this one" "C-; C-f" []
(defCommand context showCorrespondingFile "Open the corresponding .kiss/.hx file to this one" "C-; C-f" []
(showTextDocument (Uri.file (correspondingFile .fileName .document activeTextEditor))))
(defCommand context kiss.insertUTestCase "Generate a UTest test case in this .hx/.kiss file" "C-; C-t C-c" []
(defCommand context insertUTestCase "Generate a UTest test case in this .hx/.kiss file" "C-; C-t C-c" []
(awaitLet [testName (inputBox)
&sync testName
"$(.toUpperCase (testName.substr 0 1))$(testName.substr 1)"

View File

@@ -15,7 +15,7 @@
(e.delete editor.selection)
(e.insert editor.selection.active mappedText))))))
(defCommand context kiss.mapLinesSync "Transform the selected text lines using a String->String kiss function" "C-; C-l C-m" []
(defCommand context mapLinesSync "Transform the selected text lines using a String->String kiss function" "C-; C-l C-m" []
(awaitLet [mapFuncStr (inputEditor "mapLinesFunc.kiss" "a String->String function through which to map the selected lines")]
(let [:String->String mapFunc (evalString mapFuncStr)]
(_mapLinesSync (selectedText) mapFunc))))
@@ -30,6 +30,6 @@
(e.delete editor.selection)
(e.insert editor.selection.active (lines.join "\n")))))))
(defCommand context kiss.sortLinesSync "Sort the selected text lines using a (String,String)->Int comparator function" "C-; C-l C-s" []
(defCommand context sortLinesSync "Sort the selected text lines using a (String,String)->Int comparator function" "C-; C-l C-s" []
(awaitLet [compareFuncStr (inputEditor "sortLinesFunc.kiss" "a (String,String) -> Int function with which to sort the selected lines")]
(_sortLinesSync (selectedText) (if (< 0 compareFuncStr.length) (evalString compareFuncStr) Reflect.compare))))