cancel
Showing results for 
Search instead for 
Did you mean: 

VS Code project navigation breaks when using STM32-cube-clang instead of MS IntelliSense

EE_Guy817
Associate

Hello, 

I recently upgraded my STM32 CubeIDE for VS Code extension to the new release with clang integration and project navigation. When getting the popup below I went ahead and disabled IntelliSense. However, I then lost my navigation capabilities such as "jump to" etc...... 

For now, I have IntelliSense re-enabled but would like to migrate to clang. Is there a step I am missing here? 

 

EE_Guy817_0-1762267857949.png

 

1 REPLY 1
Adam Hamilton
Senior

The new Visual Studio code extension from ST uses clangd for language integration and as such is incompatible with the Microsoft C++ extension because the two will be fighting each other.

 

For the Visual Studio based extension, it makes use of CMake. CMake should also generate a database file called compile_commands.json. The command to generate this is specified in the CMakePresets.json around the top, you will see this

"cacheVariables": {
   "CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
}

In order for CMake to populate the database, CMake must know about the files, and these are, in basic form, specified with the following CMake command: target_sources and include directories should be specified with: target_include_directories

clangd uses the database file to generate an internal representation of your source code so that it can provide the intellisense and navigation capabilities.

 

I am trying to wrestle with the extension myself as I feel it is woefully incomplete, at least for my use case, which is starting from an empty project.

 

How are you starting off?

Are you creating a CMake based project from CubeMX or starting with an empty project?