"Premake" module that generates config files for clangd.
The idea is to separate compilation flags
and compilation database
.
- generate
clangd_config.yaml
with common compilation options - generate one
compile_commands.json
per 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.yaml
file (defaultfalse
)--clangd-config-json
: generate a simplecompile_commands.json
for 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
jq
to 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 |