Skip to content

Support extra extensions with optional language mapping#32

Merged
georgeh0 merged 2 commits intococoindex-io:mainfrom
ikeisuke:feat/extra-extensions
Mar 5, 2026
Merged

Support extra extensions with optional language mapping#32
georgeh0 merged 2 commits intococoindex-io:mainfrom
ikeisuke:feat/extra-extensions

Conversation

@ikeisuke
Copy link
Copy Markdown
Contributor

@ikeisuke ikeisuke commented Mar 5, 2026

Background

Some legacy PHP projects use .inc as a file extension, but it is currently not indexed and therefore excluded from code search.

Changes

  1. Add support for extra extensions (1st commit)

Users can now specify additional file extensions to index via the COCOINDEX_CODE_EXTRA_EXTENSIONS environment variable.

COCOINDEX_CODE_EXTRA_EXTENSIONS="inc,tpl"

  1. Add language mapping support (2nd commit)

Language detection is handled by the detect_code_language function in cocoindex, but some extensions like .inc are not tied to a specific language. To handle this, users can now specify the language explicitly using the ext:lang format to override detection.

COCOINDEX_CODE_EXTRA_EXTENSIONS="inc:php,yaml,tpl:html"

When no language is specified, it falls back to detect_code_language as before.

Note

Language mapping is currently handled on the caller side. If there is a better place for this (e.g. extending detect_code_language), I'm happy to adjust the approach.

Tests

All 20 tests pass

ikeisuke added 2 commits March 5, 2026 16:54
…S env var

Users can now specify additional file extensions to index without editing
source code, e.g. COCOINDEX_CODE_EXTRA_EXTENSIONS="inc,tpl"
Allow `ext:lang` format (e.g. "inc:php,yaml,tpl:html") to override
language detection for extra extensions, enabling proper AST-based
chunking for unrecognized extensions.
@badmonster0
Copy link
Copy Markdown
Member

super cool! thanks for contribution!! @georgeh0 can help take a look!

@badmonster0 badmonster0 requested a review from georgeh0 March 5, 2026 19:11
@georgeh0 georgeh0 merged commit e3ab9f0 into cocoindex-io:main Mar 5, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants