Here I wanted to share my own configuration of Visual Studio Code that I currently use when programming in Elixir. The section about Tasks and Shortcut is taken from this post: Running Elixir Tests in Visual Studio Code/ElixirLS.
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "Build",
"type": "shell",
"command": "mix compile",
"problemMatcher": [
"$mixCompileError",
"$mixCompileWarning"
],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Format Current File",
"type": "shell",
"command": "mix",
"args": ["format", "${relativeFile}"],
"options": {
"cwd": "${workspaceRoot}"
},
"problemMatcher": "$mixTestFailure",
"presentation": {
"focus": false,
"reveal": "never",
}
},
{
"label": "Run All Tests",
"type": "shell",
"command": "mix",
"args": ["test"],
"options": {
"cwd": "${workspaceRoot}"
},
"problemMatcher": [
"$mixCompileError",
"$mixCompileWarning",
"$mixTestFailure"
],
"group": {
"kind": "test",
"isDefault": true
},
"presentation": {
"focus": true,
}
},
{
"label": "Run Current Tests",
"type": "shell",
"command": "mix",
"args": ["test", "${relativeFile}"],
"options": {
"cwd": "${workspaceRoot}"
},
"problemMatcher": [
"$mixCompileError",
"$mixCompileWarning",
"$mixTestFailure"
],
"presentation": {
"focus": true,
}
},
{
"label": "Run Focused Test",
"type": "shell",
"command": "mix",
"args": ["test", "${relativeFile}:${lineNumber}"],
"options": {
"cwd": "${workspaceRoot}"
},
"problemMatcher": [
"$mixCompileError",
"$mixCompileWarning",
"$mixTestFailure"
],
"presentation": {
"focus": true,
}
}
]
}
keybindings.json
[
{
"key": "ctrl+alt-b",
"command": "workbench.action.tasks.runTask",
"args": "Build"
},
{
"key": "ctrl+alt-l",
"command": "workbench.action.tasks.runTask",
"args": "Format Current File"
},
{
"key": "ctrl+alt+t",
"command": "workbench.action.tasks.runTask",
"args": "Run All Tests"
},
{
"key": "ctrl+alt+c",
"command": "workbench.action.tasks.runTask",
"args": "Run Current Tests"
},
{
"key": "ctrl+alt+f",
"command": "workbench.action.tasks.runTask",
"args": "Run Focused Test"
}
]
- Build the project:
Ctrl + Alt + B
(it will runmix compile
) - Format Current File:
Ctrl + Alt + L
- Run All Tests:
Ctrl + Alt + T
- Run Current Tests:
Ctrl + Alt + C
- Run Focused Test:
Ctrl + Alt + F
- Close the terminal:
Ctrl + `
All of those shortcuts just open the dropdown with lists of tasks - what am I doing wrong?