"Premake" module that generates config files for clangd.
The idea is to separate compilation flags and compilation database.
- generate
clangd_config.yamlwith common compilation options - generate one
compile_commands.jsonper project
-
Put these files in a "clangd-config" subdirectory of Premake search paths.
-
Adapt your premake5.lua script, or better: create/adapt your premake-system.lua
require "clangd-config"- Generation option
--clangd-config-yaml: generate theclang.yamlfile (defaultfalse)--clangd-config-json: generate a simplecompile_commands.jsonfor each project (defaulttrue)
# Help
premake5 --help
# Generate with defaults
premake5 clangd-config
# Or
premake5 clangd-config --clangd-config-yaml=false --clangd-config-json=true- Adjust ".clangd":
Copy or move the "clangd_config.yaml" into ".clangd" if you generated it and adapt it.
Activate (uncomment) "CompilationDatabase":
- either for desired projects
- or globally (Configuration) and adapt path for a "common" compilation file (a command using
jqto merge the files can be found at the end)
If you are interested in a similar project, you may try premake-export-compile-commands.
| OS (Platform) - Date | Premake | clangd Version |
|---|---|---|
| Alpine Linux (x64) - March 2025 | 5.0.0-beta3 | 19.1.7 |