Fix “The language server crashed 5 times in the last 3 minutes.” error for VS Code C/C++ extension

From yesterday, My VS Code‘s C/C++ extension always reports “The language server crashed 5 times in the last 3 minutes.” error, and I have tried all the methods: Re-install extension, Re-start machine, re-isntall VS Code, etc. Unfortunatelly, no one works. Finally I install the VS Code - Insiders, then the problem is gone.

Configure uncrustify in Visual Studio Code

Visual Studio Code already has uncrustify extension:

After installing it, you can modify the uncrustify‘s configuration file path. On macOS: Code -> Preferences -> Settings-> Extensions -> Uncrusify configuration -> Configure Path: Osx:

Then edit settings.json:

{
    ......
    "uncrustify.configPath.osx": "/Users/nanxiao/Documents/uncrustify.cfg",
} 

Now you can format your code through “Option + shift + F” command.(You should disable C/C++ extension‘s formatting function, please refer troubleshooting . Update in 2023: for currentVisual Studio Code, it will prompt you select uncrustify or other extensions as the format tool)

BTW, you can enable formatting code when saving file function:

{
    ......
    "editor.formatOnSave": true,
}