CLANGD(1)

πŸ“¦
version 13.0.1 Β· 3 versions
, in ubuntu jammy

✨ CLANGD ✨

okay bestie, sit down, hydrate, and let me tell you about clangd πŸ’… this is the manual page for clangd 13 and it's lowkey iconic, so let's go.


🌸 NAME 🌸

clangd β€” the manual page for clangd 13. yes that's it, that's the name, she's simple and she's serving πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

OVERVIEW: clangd is a language server that gives your editor IDE-like features. like, autocomplete, go-to-def, all the good stuff. she's the main character behind the scenes so your editor can be the main character on screen πŸ’–

fr fr bestie: use her through an editor plugin, not by invoking her directly. that's the vibe. don't rawdog the language server.

for more info, go look at:

clangd accepts flags on the commandline, and also in the CLANGD_FLAGS environment variable. so you've got options, literally 😌

USAGE:

clangd [options]

πŸ‘‘ OPTIONS πŸ‘‘

🧚 Generic Options 🧚

  • --help β€” Display available options. (and --help-hidden for more, if you're nosy like that πŸ™ˆ)
  • --help-list β€” Display list of available options. (and --help-list-hidden for more πŸ‘€)
  • --version β€” Display the version of this program. she'll tell you who she is πŸ’

πŸ“ 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. she'll find it, she always does πŸ”₯
  • --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 vibe here: these are drivers that are safe to execute. clangd is literally running them. so, like, be careful who you whitelist, bestie. 🫢

⭐ 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. she's reaching outside her bubble and honestly? slay.
  • --background-index β€” Index project code in the background and persist index on disk. multi-tasking queen πŸ’…
  • --clang-tidy β€” Enable clang-tidy diagnostics. she will absolutely tell you about your problems. lovingly. πŸ’–
  • --completion-style=<value> β€” Granularity of code completion suggestions. pick your fighter:
    • =detailed β€” One completion item for each semantically distinct completion, with full type information. every single one gets her own moment ✨
    • =bundled β€” Similar completion items (e.g. function overloads) are combined. Type information shown where possible. group chat energy, they're all in one message πŸŽ€
  • --fallback-style=<string> β€” clang-format style to apply by default when no .clang-format file is found. the backup outfit when the planned outfit isn't there 😭
  • --header-insertion=<value> β€” Add #include directives when accepting code completions. two moods:
    • =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. very mindful, very demure 🧚
    • =never β€” Never insert #include directives as part of code completion. boundaries. she said no βœ‹
  • --header-insertion-decorators β€” Prepend a circular dot or space before the completion label, depending on whether an include line will be inserted or not. little dot, little hint, big brain energy πŸ”₯
  • --inlay-hints β€” Enable preview of InlayHints feature. it's giving ✨preview✨ so yk, treat it like a preview, not a promise πŸ‘€
  • --limit-references=<int> β€” Limit the number of references returned by clangd. 0 means no limit (default=1000). go off, unlimited, but the default is a chill 1000.
  • --limit-results=<int> β€” Limit the number of results returned by clangd. 0 means no limit (default=100). again: 0 = no limit, default 100. numbers, copied exactly, no cap πŸ’―
  • --project-root=<string> β€” Path to the project root. Requires remote-index-address to be set. she's not going anywhere without her plus-one 🫢
  • --remote-index-address=<string> β€” Address of the remote index server. long distance relationship, but make it indexing 🌈

πŸ’œ clangd miscellaneous options πŸ’œ

  • --check[=<string>] β€” Parse one file in isolation instead of acting as a language server. Useful to investigate/reproduce crashes or configuration problems. With --check=<filename>, attempts to parse a particular file. detective mode activated πŸ”
  • --check-lines[=<string>] β€” If specified, limits the range of tokens in -check file on which various features are tested. Example --check-lines=3-7 restricts testing to lines 3 to 7 (inclusive) or --check-lines=5 to restrict to one line. Default is testing entire file. she can zoom in or take the whole picture πŸ“Έ
  • --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. she's hiring. headcount matters πŸ’…
  • --malloc-trim β€” Release memory periodically via malloc_trim(3). self-care routine. she's doing a little cleanup, as a treat 🌸
  • --pch-storage=<value> β€” Storing PCHs in memory increases memory usages, but may improve performance. the eternal tradeoff, bestie. pick:
    • =disk β€” store PCHs on disk. old school, reliable, no RAM drama πŸ’Ύ
    • =memory β€” store PCHs in memory. fast girl, hungry girl πŸ“

🌈 clangd protocol and logging options 🌈

  • --log=<value> β€” Verbosity of log messages written to stderr. choose your volume:
    • =error β€” Error messages only. she only speaks when something's wrong 😭
    • =info β€” High level execution tracing. the group chat update πŸ“±
    • =verbose β€” Low level details. she is telling you EVERYTHING πŸ’€
  • --offset-encoding=<value> β€” Force the offsetEncoding used for character positions. This bypasses negotiation via client capabilities. she's not negotiating, she's deciding πŸ‘‘
    • =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. because she's pretty, and so is her JSON βœ¨πŸ’…

🫢 sign-off 🫢

and that's the whole page, bestie!! this was clangd 13, dated July 2023, served to you in style. go forth and let your editor be iconic. no cap, you got this. πŸ’–πŸŽ€πŸ¦‹βœ¨

CLANGD(1) β€” User Commands β€” CLANGD(1) 🌸

πŸ“¦ where this page comes from