Skip to content

docs: say how to give clangd the include paths and flags of a project - #2280

Merged
lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:docs/clangd-compile-flags
Nov 26, 2026
Merged

lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:docs/clangd-compile-flags

Conversation

@lagergren

Copy link
Copy Markdown
Collaborator

Answers the question of #1286, by @antonysouthworth-halter: how to tell clangd about the include paths (-I) and other flags of a project, so that completion and diagnostics find its headers. The clangd page didn't say.

Change

A new section of docs/user-defined-ls/clangd.md, "Tell clangd how your project is built":

  • The compilation database: clangd reads the flags from a compile_commands.json, which it looks for in the folder of the edited file, in its parents, and in a build/ subfolder of each. CMake (-DCMAKE_EXPORT_COMPILE_COMMANDS=ON), Meson and Bear (bear -- make) write one.
  • compile_flags.txt: one flag per line, for a simple project.
  • .clangd: adds flags (CompileFlags: Add: [...]).
  • --compile-commands-dir: in the command of the language server, for a compilation database in another folder.
  • Links: to clangd's Project setup and Configuration pages.

Docs only, so CI runs no tests. The link check reports 0 problems, and the clangd links and the #project-setup anchor resolve.

clangd reads them from a compile_commands.json, a compile_flags.txt or a .clangd file, not from LSP4IJ. The clangd page now says where clangd looks for them, how CMake, Meson and Bear write a compilation database, and how --compile-commands-dir points clangd at one in another folder. This answers the question of redhat-developer#1286.
@lagergren lagergren added this to the 0.30.2 milestone Nov 26, 2026
@lagergren lagergren added the documentation Improvements or additions to documentation label Nov 26, 2026
@coderabbitai

coderabbitai Bot commented Nov 26, 2026

Copy link
Copy Markdown

Warning

Review limit reached

This review ran on the open-source allowance, not this organization's plan, because the pull request author doesn't have an assigned seat. Waiting won't change this — ask an organization admin to assign them a seat, or add seats in Billing if every seat is already assigned, then retry.

Next included review available in 22 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 21d21fa4-1d48-40c4-864f-1d80626538ad
Commits

Reviewing files that changed from the base of the PR and between 5e4c130 and 3cbd5ba.

Files selected for processing: 1

  • docs/user-defined-ls/clangd.md

@lagergren
lagergren merged commit 62d8940 into redhat-developer:main Nov 26, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant