Repository navigation
docs: say how to give clangd the include paths and flags of a project - #2280
Merged
lagergren merged 1 commit intoNov 26, 2026
Merged
Conversation
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.
|
Warning Review limit reachedThis 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. View limit details
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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":compile_commands.json, which it looks for in the folder of the edited file, in its parents, and in abuild/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.Docs only, so CI runs no tests. The link check reports 0 problems, and the clangd links and the
#project-setupanchor resolve.