I have a simple main.kt
file in VS Code:
fun main() {
println("Hello world");
}
I tried pressing F5 (I have a Node background) and it says "You don't have an extension for debugging Kotlin." I installed vscode-runner
by HarryHopkinson. F5 still give the same message, but Ctrl-Alt-N builds and runs the program. It seems to be executing the following:
cd "d:\Documents\kotlin\hello" && kotlinc main.kt -include-runtime -d main.jar && java -jar main.jar
From where does vscode-runner
get the parameters to execute this set of instructions?
It just uses the executor map setting. The default value is defined in https://github.com/formulahendry/vscode-code-runner/blob/master/package.json, where it currently has the following:
".kt": "cd $dir && kotlinc $fileName -include-runtime -d $fileNameWithoutExt.jar && java -jar $fileNameWithoutExt.jar",
".kts": "kotlinc -script",
More info about the executor map setting and the template variables that can be used in it can be found at https://github.com/formulahendry/vscode-code-runner/blob/master/README.md#configuration.
F5's default binding in VS Code is the following:
{ "key": "f5", "command": "debug.openView", "when": "!debuggersAvailable" }, { "key": "f5", "command": "workbench.action.debug.start", "when": "debuggersAvailable && debugState == 'inactive'" }, { "key": "f5", "command": "workbench.action.debug.continue", "when": "debugState == 'stopped'" },