Search code examples
c++clangarduino-esp8266platformio

VSCode clang-format command keeps not available


I am running VSCode 1.95.0 on Win10 64 applying Platformio for programming eg. ESP8266. I want to use the formatting feature of clang. Downloaded clang+llvm-18.1.8-x86_64-pc-windows-msvc.tar.xz and extracted it to folder C:\Program Files (x86)\LLVM.The clang executables are in the subfolder /bin.
When trying to format I get following message: The 'c::\Program Files (x86)\LLVM\bin\clang-format.exe' command is not available. Please check your clang-format.executable user setting and ensure it is installed. The clang-format extension v1.9.0 by Xaver is installed. See settings.json

{
"launch": {
    "configurations": [
    
    ]
},
"workbench.colorTheme": "Visual Studio Dark - C++",
"[python]": {
    "editor.formatOnType": true
},
"editor.defaultFormatter": "xaver.clang-format",
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"git.openRepositoryInParentFolders": "never",
"clang-format.executable": "c::\\Program Files (x86)\\LLVM\\bin\\clang-format.exe"
}
}

I created a clang-format configuration file that I placed in the src folder of the project named clang-format:

{BasedOnStyle:   Microsoft
SpaceAfterLogicalNot: true
SpaceAfterTemplateKeyword: false
}

putting the clang-format file to other folders did not help. Which folder is the right one for this configuration file. In front ot he filename is a purple excalmation mark that indicates tha the file is a yml file. Is this correct?

How to get it working?

Reading docs, checking subject on Youtube videos and tutorials, searching the web.


Solution

  • Change that line, you have a mistake.

    "clang-format.executable": "C:\\Program Files (x86)\\LLVM\\bin\\clang-format.exe"