use :Void lambdas in kiss-vscode

This commit is contained in:
2021-03-17 11:21:52 -06:00
parent ca206ccc7e
commit 023648b90e
2 changed files with 14 additions and 21 deletions

View File

@@ -61,7 +61,7 @@
(parser.parseString
(convertToHScript kiss))))
(defun runCommand [&opt command]
(defun :Void runCommand [&opt command]
(if command
{(set lastCommand command) ((dictGet commands command) (selectedText))}
(let [commandList
@@ -74,24 +74,20 @@
alwaysShow null))]
(awaitLet [chosenCommand (quickPick commandList)]
(set lastCommand chosenCommand.label)
((dictGet commands chosenCommand.label) (selectedText)))))
(return))
((dictGet commands chosenCommand.label) (selectedText))))))
(defun runLastCommand [&opt _]
(defun :Void runLastCommand [&opt _]
(if lastCommand
(runCommand lastCommand)
(errorMessage "No Kiss command was run previously."))
(return))
(errorMessage "No Kiss command was run previously.")))
(defun runKeyboardShortcut [&opt _]
(defun :Void runKeyboardShortcut [&opt _]
// TODO
(errorMessage "Keyboard shortcut commands are not yet implemented")
(return))
(errorMessage "Keyboard shortcut commands are not yet implemented"))
(defun registerCommand [description command]
(dictSet commands description command))
(defun registerBuiltins []
(defun :Void registerBuiltins []
(registerCommand "Rerun last command" runLastCommand)
(registerCommand "Run a keyboard shortcut command" runKeyboardShortcut)
(return))
(registerCommand "Run a keyboard shortcut command" runKeyboardShortcut))

View File

@@ -62,29 +62,26 @@
(context.subscriptions.push
(Vscode.commands.registerCommand
"kiss.runCommand"
(lambda []
(lambda :Void []
(if config
(.runCommand (the KissConfig config))
(Vscode.window.showErrorMessage "Can't run commands! No config is loaded."))
(return))))
(Vscode.window.showErrorMessage "Can't run commands! No config is loaded.")))))
(context.subscriptions.push
(Vscode.commands.registerCommand
"kiss.runLastCommand"
(lambda []
(lambda :Void []
(if config
(.runLastCommand (the KissConfig config))
(Vscode.window.showErrorMessage "Can't run commands! No config is loaded."))
(return))))
(Vscode.window.showErrorMessage "Can't run commands! No config is loaded.")))))
(context.subscriptions.push
(Vscode.commands.registerCommand
"kiss.runKeyboardShortcut"
(lambda []
(lambda :Void []
(if config
(.runKeyboardShortcut (the KissConfig config))
(Vscode.window.showErrorMessage "Can't run commands! No config is loaded."))
(return))))
(Vscode.window.showErrorMessage "Can't run commands! No config is loaded.")))))
// TODO overload Prelude.print to use showInformationMessage