espressif / vscode-esp-idf-extension

Visual Studio Code extension for ESP-IDF projects
https://docs.espressif.com/projects/vscode-esp-idf-extension/en/latest/
Apache License 2.0
1.08k stars 307 forks source link

[Feature Request]: Better support for clangd extenstion out of the box (VSC-1527) #1352

Open mmrein opened 4 days ago

mmrein commented 4 days ago

Is your feature request related to a problem? Please describe.

  1. clangd extension does not recognize correct system headers

    • Temporary workaround is to add Arguments for clangd server with path to xtensa compiler, for example: --query-driver=/home/user/.espressif/tools/xtensa-esp-elf/esp-14.2.0_20240906/xtensa-esp-elf/bin/xtensa-esp32-elf-gcc.
    • This command has to be changed manually every time target or IDF version changes
  2. clangd extension only works correctly with clangd path set to espressif one

    • For example: /home/user/.espressif/tools/esp-clang/esp-18.1.2_20240912/esp-clang/bin/clangd
    • This path has to be changed manually every time IDF version changes

Describe the solution you'd like

I would prefer to use clangd for code navigation over MS C/C++ extension. Main reason being that it supports Inactive code block background highlight. AFAIK this is at this point the only IDE option for Espressif devices that supports this feature.

As new user of ESP-IDF in VSCode and clang in general, it took me far too much time to find at least those workarounds so I could work on my project in a way I was used to.

There is c_cpp_properties.json file for MS C/C++ extension - I would expect something simillar could be done for clangd support too?

Describe alternatives you've considered

brianignacio5 commented 5 hours ago

You can:

1) Configure Microsoft C/C++ extension to use Clang as described here: https://code.visualstudio.com/docs/cpp/config-clang-mac

2) Use the clang vscode extension: https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd

Then when you build your project, a compile_commands.json is generated which can be used for these extensions as described in https://docs.espressif.com/projects/vscode-esp-idf-extension/en/latest/configureproject.html#c-and-c-code-navigation-and-syntax-highlight