diff --git a/projects/kiss-vscode-api/src/Util.kiss b/projects/kiss-vscode-api/src/Util.kiss index ba82e4c7..b570784f 100644 --- a/projects/kiss-vscode-api/src/Util.kiss +++ b/projects/kiss-vscode-api/src/Util.kiss @@ -167,11 +167,10 @@ // Example: /* - (defCommand myExt.customCommand "Custom command that does something" "C-; C-c" [] ) + (defCommand customCommand "Custom command that does something" "C-; C-c" [] ) */ -(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) diff --git a/projects/kiss-vscode/package.json b/projects/kiss-vscode/package.json index abf67c92..71c12e7b 100644 --- a/projects/kiss-vscode/package.json +++ b/projects/kiss-vscode/package.json @@ -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": [ diff --git a/projects/kiss-vscode/src/commands/ExtensionTools.kiss b/projects/kiss-vscode/src/commands/ExtensionTools.kiss index 2915f62d..b55e17fd 100644 --- a/projects/kiss-vscode/src/commands/ExtensionTools.kiss +++ b/projects/kiss-vscode/src/commands/ExtensionTools.kiss @@ -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)) \ No newline at end of file + (updateExtension)) \ No newline at end of file diff --git a/projects/kiss-vscode/src/commands/KissTools.kiss b/projects/kiss-vscode/src/commands/KissTools.kiss index 8c44568d..1f06adef 100644 --- a/projects/kiss-vscode/src/commands/KissTools.kiss +++ b/projects/kiss-vscode/src/commands/KissTools.kiss @@ -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)" diff --git a/projects/kiss-vscode/src/commands/Lines.kiss b/projects/kiss-vscode/src/commands/Lines.kiss index 5da29825..b7558ecf 100644 --- a/projects/kiss-vscode/src/commands/Lines.kiss +++ b/projects/kiss-vscode/src/commands/Lines.kiss @@ -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)))) \ No newline at end of file