Next, configure your project. Go to View
> Command Palette
and enter ESP-IDF: SDK Configuration Editor
to adjust ESP-IDF project settings.
C and C++ Code Navigation and Syntax Highlighting
Note
C and C++ code navigation is automatically configured if you create the project as described in Configure Your Project. Those commands generate the {PROJECT_DIRECTORY_PATH}/.vscode/c_cpp_properties.json
file.
For code navigation and C/C++ syntax highlighting, you can use Microsoft C/C++ extension, LLVM clangd extension, or any other preferred extension.
Usually C/C++ language extensions rely on a file called compile_commands.json
, which is located in your project build directory. You can generate this file using the ESP-IDF: Run idf.py reconfigure task
.
For LLVM clangd extension, only compile_commands.json
is needed. For Microsoft C/C++ extension, a configuration file is located at {PROJECT_DIRECTORY_PATH}/.vscode/c_cpp_properties.json
. This file can be generated by creating a project using ESP-IDF: New Project
, ESP-IDF: Show Example Projects
command, or by using the ESP-IDF: Add .vscode Configuration Folder
command on an existing ESP-IDF projects.
The file structure is as follows:
{
"configurations": [
{
"name": "ESP-IDF",
"compilerPath": "/path/to/toolchain-gcc",
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
"includePath": [
"${config:idf.espIdfPath}/components",
"${config:idf.espIdfPathWin}/components/",
"${workspaceFolder}/"
],
"browse": {
"path": [
"${config:idf.espIdfPath}/components",
"${config:idf.espIdfPathWin}/components",
"${workspaceFolder}"
]
}
}
]
}
If compile_commands.json
is not defined, Microsoft C/C++ extension will browse the provided ESP-IDF path to resolve code navigation.