Allow custom extension → language mapping (opt-in, zero-config preserved)
CodeGraph's file-extension → language mapping is hardcoded, with no way for a project to customize it. Codebases that use non-standard extensions for a supported language will see a significant portion of their files silently skipped or misclassified — including business-critical layers that developers query most. We've verified that parsing works perfectly once these extensions are mapped to the correct grammar; the only gap is in the discovery/mapping step. We propose an opt-in, project-scoped extension override that merges on top of built-in defaults with user mappings taking precedence — turning today's fragile manual source patch into a one-time, version-controlled setting with zero impact on existing projects.
Using this as the canonical issue for custom extension→language mapping. Folding in #767 (support for non-preset languages/extensions, e.g. .ets). 👍 here to signal demand.
Our codebase uses .C for C++ and .c for C. As the mapping in CodeGraph is not case sensitive, if the feature proposed in this issue is added, it would be nice if it would check whether .C is mapped to both C++ and C and if so, handle it how it currently handles .H where it looks inside the file to resolve the ambiguity.
Shipped in #955 (on main, will go out in the next release). Thanks for the well-scoped writeup — the "parsing already works, the gap is only discovery" framing was exactly right.
Drop a codegraph.json at your project root:
{
"extensions": {
".dota_lua": "lua",
".tpl": "php"
}
}
A few notes on how it behaves:
- Opt-in & shareable — it's a committed file, so the mapping travels with the repo for the whole team. No file = zero-config, exactly as before.
- Merges on top of the built-ins, your mappings win — so you can also re-point a built-in if you ever need to (e.g.
".h": "cpp"). - Never fatal — a typo'd language id or a malformed file is warned about and skipped, not a hard error.
- Each value is a supported language id (the language list).
- Run
codegraph indexafter adding or changing mappings so already-scanned files pick up the new extensions.
Documented in the README's Configuration section and the docs site. Give it a try once the next release lands and let me know if anything's off!