CLANGD(1)

πŸ“¦ version 11.1.0, in ubuntu jammy

πŸ’– clangd β€” bestie's guide to the language server πŸ’–

okay so real talk: this is the manual page for clangd 11, from the User Commands section of your friendly neighborhood man pages. she's a whole icon, and you're gonna love her. let's get into it 🫢


✨ NAME ✨

clangd β€” manual page for clangd 11


🌸 DESCRIPTION 🌨️

OVERVIEW: clangd is a language server that provides IDE-like features to editors. she's the girl in the back giving your editor main character energy β€” autocomplete, diagnostics, the works. πŸ’…

🚨 bestie listen: it should be used via an editor plugin rather than invoked directly. like, she can be run raw but that's not the vibe she's going for.

want more info? the links are right here, no cap:

https://clangd.llvm.org/
https://microsoft.github.io/language-server-protocol/

clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment variable. yes, both. she's flexible like that ✨

USAGE:

clangd [options]

OPTIONS:


πŸŽ€ Generic Options πŸŽ€

  • --help β€” Display available options (there's also --help-hidden for more πŸ‘€)
  • --help-list β€” Display list of available options (and --help-list-hidden for more, iykyk)
  • --version β€” Display the version of this program

🌈 clangd compilation flags options 🌈

  • --compile-commands-dir=<string> β€” Specify a path to look for compile_commands.json. and if that path is invalid? no stress, clangd will look in the current directory and parent paths of each source file πŸ•΅οΈ
  • --query-driver=<string> β€” Comma separated list of globs for white-listing gcc-compatible drivers that are safe to execute. Drivers matching any of these globs will be used to extract system includes. e.g. /usr/bin/**/clang-*,/path/to/repo/**/g++-*
⚠️ note the word safe to execute β€” you're letting clangd run these, so don't go white-listing random nonsense fr fr

πŸ’œ clangd feature options πŸ’œ

  • --all-scopes-completion β€” If set to true, code completion will include index symbols that are not defined in the scopes (e.g. namespaces) visible from the code completion point. Such completions can insert scope qualifiers
  • --background-index β€” Index project code in the background and persist index on disk. she works while you vibe πŸ’…
  • --clang-tidy β€” Enable clang-tidy diagnostics
  • --clang-tidy-checks=<string> β€” List of clang-tidy checks to run (this will override .clang-tidy files). Only meaningful when -clang-tidy flag is on
  • --completion-style=<value> β€” Granularity of code completion suggestions
    • =detailed β€” One completion item for each semantically distinct completion, with full type information
    • =bundled β€” Similar completion items (e.g. function overloads) are combined. Type information shown where possible
  • --cross-file-rename β€” Enable cross-file rename feature.
  • --fallback-style=<string> β€” clang-format style to apply by default when no .clang-format file is found
  • --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 space before the completion label, depending on whether an include line will be inserted or not
  • --limit-results=<int> β€” Limit the number of results returned by clangd. 0 means no limit (default=100)
  • --recovery-ast β€” Preserve expressions in AST for broken code (C++ only).
  • --suggest-missing-includes β€” Attempts to fix diagnostic errors caused by missing includes using index

πŸ¦‹ clangd miscellaneous options πŸ¦‹

  • --enable-config β€” Read user and project configuration from YAML files. Project config is from a .clangd file in the project directory. User config is 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. Background index also uses this many workers.
  • --pch-storage=<value> β€” Storing PCHs in memory increases memory usages, but may improve performance
    • =disk β€” store PCHs on disk
    • =memory β€” store PCHs in memory

πŸ’€ clangd protocol and logging options πŸ’€

  • --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
    • =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). Comma separated list of '<client_path>=<server_path>' pairs, the first entry matching a given path is used. e.g. /home/project/incl=/opt/include,/home/project=/workarea/project
  • --pretty β€” Pretty-print JSON output

and that's the whole page, bestie, you ate that πŸ“

sign-off: this was clangd 11, dated January 2022, from the User Commands corner of the man page universe. go forth and let your editor slay πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from