The extension → language table was hardcoded, so a codebase using a
non-standard extension for a supported language (e.g. `.dota_lua` for Lua)
had those files silently skipped — no way to opt them in short of patching
the source.
Add an opt-in, project-scoped `codegraph.json` at the repo root:
{ "extensions": { ".dota_lua": "lua", ".tpl": "php" } }
Mappings merge on top of the built-in defaults and take precedence (so a
built-in can be re-pointed, e.g. `.h` → `cpp`). Absent or malformed config
is the zero-config default — byte-identical to prior behavior; an invalid
target language or unparseable file is warned-and-skipped, never fatal.
Implementation:
- New `src/project-config.ts` — `loadExtensionOverrides(rootDir)`, validated
against `isLanguageSupported`, mtime-cached per root.
- `detectLanguage` / `isSourceFile` gain an optional `overrides` arg
(omitting it is the existing behavior).
- Overrides threaded per-operation through every extraction call site
(scan/walk gates, git change-detection, grammar selection, extraction,
the file watcher), resolved from the project root — no process-global
state, so the multi-project daemon stays isolated. The parse worker
receives the resolved language in its message.
Tests: 13 new cases (unit, loader validation/normalization/caching, and a
full-index integration proving a custom-extension file is extracted while
the zero-config path indexes nothing). Worker path smoke-tested via the
built CLI.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
ba209d9489
commit
d1121e46f0
@@ -585,9 +585,10 @@ that drive the graph directly: `DatabaseConnection`, `QueryBuilder`,
|
||||
|
||||
## Configuration
|
||||
|
||||
There isn't any — CodeGraph is zero-config, with **no config file** to write or
|
||||
keep in sync. Language support is automatic from the file extension; there's
|
||||
nothing to wire up per language.
|
||||
Next to none — CodeGraph is **zero-config by default**, with nothing to write or
|
||||
keep in sync to get started. Language support is automatic from the file
|
||||
extension; there's nothing to wire up per language. The one optional file is for
|
||||
mapping [custom file extensions](#custom-file-extensions).
|
||||
|
||||
What it skips out of the box:
|
||||
|
||||
@@ -605,6 +606,29 @@ add a negation — `!vendor/`. The defaults apply uniformly, so committing a
|
||||
dependency or build directory doesn't force it into the graph; the `.gitignore`
|
||||
negation is the explicit opt-in.
|
||||
|
||||
### Custom file extensions
|
||||
|
||||
If your project uses a non-standard extension for a [supported
|
||||
language](#supported-languages) — say `.dota_lua` for Lua, or `.tpl` for PHP —
|
||||
those files are skipped by default, because the extension isn't one CodeGraph
|
||||
recognizes. Map them with an optional **`codegraph.json`** at your project root:
|
||||
|
||||
```json
|
||||
{
|
||||
"extensions": {
|
||||
".dota_lua": "lua",
|
||||
".tpl": "php"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Each value is a supported language id. The mappings merge on top of the built-in
|
||||
defaults and win on conflict, so you can also re-point a built-in (e.g.
|
||||
`".h": "cpp"`). Commit the file to share the mapping with your team. A typo'd
|
||||
language or a malformed file is warned about and skipped — it never breaks
|
||||
indexing — and a project with no `codegraph.json` behaves exactly as before.
|
||||
Re-index (`codegraph index`) after adding or changing mappings.
|
||||
|
||||
## Telemetry
|
||||
|
||||
CodeGraph collects **anonymous usage statistics** — which tools and commands get
|
||||
|
||||
Reference in New Issue
Block a user