This script automates the setup of a modern C++ development environment on Debian/Ubuntu-based systems for use with Visual Studio Code (VS Code).
It installs essential Clang tools, build utilities, and configures VS Code extensions for a clean, standardized workflow.
Automatically installs:
clang-16,clangd-16,clang-tidy-16,clang-format-16cmake,ninja-build
All via the system package manager (apt).
Sets the newly installed Clang tools as the default system-wide versions:
clangd→clangd-16clang-tidy→clang-tidy-16clang-format→clang-format-16
Automatically installs recommended extensions:
- C/C++ Language Support:
llvm-vs-code-extensions.vscode-clangd - CMake Tools:
ms-vscode.cmake-tools - Enhanced Diagnostics:
usernamehw.errorlens
Generates workspace-specific configuration files for:
- VS Code (
.vscode/settings.json) - Clang Format (
.clang-format) - Clangd (
.clangd)
These ensure consistent formatting, diagnostics, and code analysis across your workspace.
- Save the
setup.shscript in your project root. - Open a terminal in that directory.
- Make it executable:
chmod +x setup.sh
- Run the script:
You may be prompted for your password to install system packages.
./setup.sh
- Reload VS Code to apply all settings.
Configures VS Code to:
- Use
clangdas the language server and formatter - Disable the default IntelliSense engine to avoid conflicts
- Enable format-on-save and visual rulers
{
"clangd.arguments": [
"--background-index",
"--clang-tidy",
"--header-insertion=iwyu",
"--compile-commands-dir=${workspaceFolder}/build/"
],
"C_Cpp.intelliSenseEngine": "Disabled",
"editor.defaultFormatter": "llvm-vs-code-extensions.vscode-clangd",
"editor.formatOnSave": true,
"editor.rulers": [79]
}Defines a Google-style formatting profile:
BasedOnStyle: GoogleSpecifies compiler flags, diagnostics, and linting configuration.
CompileFlags:
Add: [
"-std=c++98",
"-Wall",
"-Wextra",
"-Werror",
"-Wpedantic"
]
Diagnostics:
ClangTidy:
Add: [
"bugprone-argument-comment",
"bugprone-parent-virtual-call",
"readability-qualified-auto",
"readability-redundant-string-cstr",
"modernize-pass-by-value"
]
Remove: ["*"]
Index:
Background: Build- Designed for Debian/Ubuntu systems only.
- Requires sudo privileges to install system packages.
- Compatible with VS Code (not VS Code Insiders or OSS builds).
After running the script, you’ll have a fully configured C++ environment featuring:
✅ Modern Clang tools
✅ Linting and formatting integration
✅ CMake + Ninja build support
✅ Seamless VS Code experience
extremely gay
BraceWrappingchoices