CLANGD(1)

πŸ“¦
version 21.1.8 Β· 3 versions
, in ubuntu stonking

πŸ’… CLANGD β€” ok bestie, sit down, we're learning the manual page for clangd 21


🌸 NAME 🌸

clangd β€” the manual page for clangd 21, aka your new favorite language server, no cap πŸ’–


✨ DESCRIPTION ✨

OVERVIEW: clangd is a language server that provides IDE-like features to editors.

Okay so here's the tea, bestie πŸ«– β€” you do not just run this thing directly like some kind of feral gremlin. It's supposed to be used via an editor plugin, not invoked by hand. Periodt.

Want more info? Go read these, they're iconic:

And here's a lil detail that matters: clangd takes flags on the commandline, AND from the CLANGD_FLAGS environment variable. Both. Simultaneously. Main character energy fr fr ✨

USAGE:

clangd [options]

OPTIONS: β€” yes we're doing all of them, nobody's skipping anything in this house πŸ’…


🌈 Generic Options

Your basic-starter-pack flags, the ones every LLVM tool lowkey has:

  • --help β€” Shows you the available options. Want the secret extra ones? That's --help-hidden, bestie πŸ™ˆ
  • --help-list β€” Shows you the list of available options. Again, --help-list-hidden for the hidden stash πŸ‘€
  • --version β€” Displays the version of this program. Simple. Clean. Iconic. ⭐

🧚 clangd compilation flags options

This is the "where do I find stuff and who am I allowed to run" section:

  • --compile-commands-dir=<string> β€” Tell clangd a path to go look for compile_commands.json. And if that path is invalid? πŸ’€ clangd just goes "whatever" and looks in the current directory and the parent paths of each source file instead. Resilient queen.
  • --query-driver=<string> β€” A comma separated list of globs that white-lists gcc-compatible drivers that are safe to execute. Anything matching those globs gets used to extract system includes. Example, feel free to copy this exactly: /usr/bin/**/clang-*,/path/to/repo/**/g++-*

πŸ¦‹ clangd feature options

The fun ones. The glow-up ones. The ones that make your editor feel like a whole vibe:

  • --all-scopes-completion β€” If set to true, code completion will include index symbols that are not defined in the scopes (like namespaces) visible from the code completion point. Yeah, such completions can insert scope qualifiers. It's giving overachiever and we love that πŸ’–
  • --background-index β€” Index project code in the background and persist that index on disk. Set it and forget it, bestie ✨
  • --background-index-priority=<value> β€” Thread priority for building the background index. Heads up: the effect of this flag is OS-specific, so your mileage may vary πŸŽ€
    • =background β€” Minimum priority, runs on idle CPUs. May leave 'performance' cores unused. It's the chill one, it's napping 😴
    • =low β€” Reduced priority compared to interactive work.
    • =normal β€” Same priority as other clangd work. The default-ish balanced queen πŸ‘‘
  • --clang-tidy β€” Enable clang-tidy diagnostics. Yes it'll yell at you. That's the point πŸ’€
  • --completion-style=<value> β€” Granularity of code completion suggestions:
    • =detailed β€” One completion item for each semantically distinct completion, with full type information. Maximalist. Thorough. Slay.
    • =bundled β€” Similar completion items (e.g. function overloads) are combined. Type information shown where possible. Minimalist queen πŸŽ€
  • --experimental-modules-support β€” Experimental support for standard c++ modules. It says experimental in the name, bestie, proceed with the appropriate amount of caution πŸ™ˆ
  • --fallback-style=<string> β€” The clang-format style to apply by default when no .clang-format file is found.
  • --function-arg-placeholders=<string> β€” When disabled (0), completions contain only parentheses for function calls. When enabled (1), completions also contain placeholders for method parameters.
  • --header-insertion=<value> β€” Add #include directives when accepting code completions:
    • =iwyu β€” Include what you use. Insert the owning header for top-level symbols, unless the header is already directly included or the symbol is forward-declared.
    • =never β€” Never insert #include directives as part of code completion.
  • --header-insertion-decorators β€” Prepend a circular dot or a space before the completion label, depending on whether an include line will be inserted or not. Cute lil visual cue πŸŽ€
  • --import-insertions β€” If header insertion is enabled, add #import directives when accepting code completions or fixing includes in Objective-C code.
  • --limit-references=<int> β€” Limit the number of references returned by clangd. 0 means no limit (default=1000).
  • --limit-results=<int> β€” Limit the number of results returned by clangd. 0 means no limit (default=100).
  • --project-root=<string> β€” Path to the project root. Requires remote-index-address to be set, so don't be out here setting it solo, it needs its bestie 🫢
  • --remote-index-address=<string> β€” Address of the remote index server.
  • --rename-file-limit=<int> β€” Limit the number of files to be affected by symbol renaming. 0 means no limit (default=50).

πŸ“ clangd miscellaneous options

The grab-bag section, the random drawer in your desk that somehow has everything:

  • --check[=<string>] β€” Parse one file in isolation instead of acting as a language server. Genuinely useful to investigate/reproduce crashes or configuration problems. With --check=<filename>, it attempts to parse that particular file.
  • --enable-config β€” Read user and project configuration from YAML files.
    • Project config comes from a .clangd file in the project directory.
    • User config comes from clangd/config.yaml in the following directories:
      • Windows: %USERPROFILE%\AppData\Local
      • Mac OS: ~/Library/Preferences/
      • Others: $XDG_CONFIG_HOME, usually ~/.config
    • Configuration is documented at https://clangd.llvm.org/config.html
  • -j <uint> β€” Number of async workers used by clangd. The background index also uses this many workers, so pick a number your poor CPU can handle 😭
  • --malloc-trim β€” Release memory periodically via malloc_trim(3).
  • --pch-storage=<value> β€” Storing PCHs in memory increases memory usage, but may improve performance. Pick your struggle:
    • =disk β€” store PCHs on disk
    • =memory β€” store PCHs in memory

πŸ’œ clangd protocol and logging options

For when you need to know what's actually going on in there:

  • --log=<value> β€” Verbosity of log messages written to stderr:
    • =error β€” Error messages only
    • =info β€” High level execution tracing
    • =verbose β€” Low level details
  • --offset-encoding=<value> β€” Force the offsetEncoding used for character positions. This bypasses negotiation via client capabilities, so it's a "I said what I said" move πŸ’…
    • =utf-8 β€” Offsets are in UTF-8 bytes
    • =utf-16 β€” Offsets are in UTF-16 code units
    • =utf-32 β€” Offsets are in unicode codepoints
  • --path-mappings=<string> β€” Translates between client paths (as seen by a remote editor) and server paths (where clangd sees files on disk). It's a comma separated list of '<client_path>=<server_path>' pairs, and the first entry matching a given path is used. Example, copy it exactly: /home/project/incl=/opt/include,/home/project=/workarea/project
  • --pretty β€” Pretty-print JSON output. It's just nicer to look at, okay? ✨

Okay that's literally the whole thing, bestie. Go forth, configure your editor plugin, and let clangd handle the rest 🫢

🌸 That was clangd 21, from September 2026, manual page CLANGD(1) β€” ily, go slay your compilation errors πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from