CLANGD(1)

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

πŸ¦‹ CLANGD πŸ¦‹

okay so bestie, welcome to the clangd manual page β€” that's section 1 of the User Commands manual, iykyk. grab a strawberry πŸ“, sit down, and let's get into it.


🌸 NAME 🌸

clangd β€” it's the manual page for clangd 15, and it's literally about to change your whole editor experience.


✨ DESCRIPTION ✨

OVERVIEW: clangd is a language server that provides IDE-like features to editors. no cap, that's the whole vibe.

🫢 the important part (read this one)

It should be used via an editor plugin rather than invoked directly. for real, don't just rawdog it in your terminal. for more information, see:

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. iconic behaviour.)

USAGE:

clangd [options]

πŸŽ€ OPTIONS:


⭐ Generic Options:

  • --help β€” Display available options (--help-hidden for more)
  • --help-list β€” Display list of available options (--help-list-hidden for more)
  • --version β€” Display the version of this program

🌈 clangd compilation flags options:

  • --compile-commands-dir=<string> β€” Specify a path to look for compile_commands.json. If path is invalid, 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++-*

πŸ’… 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.
  • --background-index-priority=<value> β€” Thread priority for building the background index. The effect of this flag is OS-specific.
    • =background β€” Minimum priority, runs on idle CPUs. May leave 'performance' cores unused.
    • =low β€” Reduced priority compared to interactive work.
    • =normal β€” Same priority as other clangd work.
  • --clang-tidy β€” Enable clang-tidy diagnostics
  • --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
  • --fallback-style=<string> β€” clang-format style to apply by default when no .clang-format file is found
  • --function-arg-placeholders β€” When disabled, completions contain only parentheses for function calls. When enabled, 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 space before the completion label, depending on whether an include line will be inserted or not
  • --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.
  • --remote-index-address=<string> β€” Address of the remote index server

🧚 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.
  • --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.
  • --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
  • -j <uint> β€” Number of async workers used by clangd. Background index also uses this many workers.
  • --malloc-trim β€” Release memory periodically via malloc_trim(3).
  • --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

ngl, that's the whole page. every flag, every default, every = value β€” all of it, no skips, periodt. πŸ’–

this has been clangd 15, from July 2023 β€” the CLANGD(1) manual page, bestie. go forth and get those IDE features in your editor. slay. πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from