Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Generate dynamic language mapping#1256

Merged
alanhamlett merged 1 commit intodevelopfrom
feature/dynamic-lang-map
Jan 7, 2026
Merged

Generate dynamic language mapping#1256
alanhamlett merged 1 commit intodevelopfrom
feature/dynamic-lang-map

Conversation

@gandarez
Copy link
Member

@gandarez gandarez commented Jan 6, 2026

Summary

  • Bump Chroma to latest version (v2.21.1).
  • Changed language_gen.go to automatically generate test entries in language_test.go. The generator now:
    • Reads all Chroma lexers and generates:
      • stringToLanguage and languageToString maps (excluding "unknown"/LanguageUnknown)
      • chromaToLanguage and languageToChroma maps
    • Generates languageTests() entries: These are the primary string values for each Language constant (e.g., "Go" → LanguageGo). The entries respect priority overrides from the priority section in language.go.
    • Generates languageTestsAliases() entries: These are aliases that parse to Language constants but differ from the primary string. They include:
      • Chroma lexer names and aliases that differ from the primary Language string
      • Priority overrides (secondary strings that also map to the same Language)
      • chromaPriority entries
  • Added new Language constants: C3, Kakoune, and RGBDS Assembly were new Chroma languages that needed to be added.
  • Added chromaPriority entries: Protocol Buffer Text Format → LanguageProtocolBuffer, WebAssembly Text Format → LanguageWebAssembly
  • Updated test skip list: Added entries to TestLanguage_StringChroma_AllLexersSupported for Chroma lexers that map to existing Language constants via chromaPriority (since StringChroma() returns the primary Chroma name, not the alias).

The generated test file now has:
802 languageTests entries (primary string values)
212 languageTestsAliases entries (aliases from Chroma and priority overrides)

@gandarez gandarez self-assigned this Jan 6, 2026
@gandarez gandarez force-pushed the feature/dynamic-lang-map branch from efb0a9a to be97c14 Compare January 6, 2026 16:41
@gandarez gandarez force-pushed the feature/dynamic-lang-map branch from be97c14 to e7a3298 Compare January 6, 2026 19:47
@gandarez gandarez marked this pull request as ready for review January 6, 2026 19:56
@gandarez gandarez enabled auto-merge January 6, 2026 19:56
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR automates language mapping generation by reading all Chroma lexers dynamically and generating mappings, tests, and handling aliases. Key improvements include upgrading Chroma to v2.21.1 and adding support for new languages (C3, Kakoune, RGBDS Assembly).

  • Replaces manual map creation in language_maps.go with automated generation from Chroma's lexer registry
  • Generates comprehensive test coverage with 802 primary string tests and 212 alias tests
  • Adds chromaPriority entries for Protocol Buffer Text Format and WebAssembly Text Format

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/heartbeat/language_gen.go Complete rewrite to generate mappings from Chroma lexers instead of parsing existing maps
pkg/heartbeat/language_generated.go Generated file with all language mappings (stringToLanguage, chromaToLanguage, languageToString, languageToChroma)
pkg/heartbeat/language.go Added new Language constants (C3, Kakoune, RGBDS Assembly) and chromaPriority documentation
pkg/heartbeat/language_test.go Auto-generated test entries reorganized alphabetically with 802 tests and 212 alias tests
go.mod Upgraded Chroma from v2.20.0 to v2.21.1

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gandarez gandarez disabled auto-merge January 6, 2026 20:12
Copy link
Member

@alanhamlett alanhamlett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is perfect!

@alanhamlett alanhamlett merged commit 3a197b9 into develop Jan 7, 2026
45 checks passed
@alanhamlett alanhamlett deleted the feature/dynamic-lang-map branch January 7, 2026 01:03
@codecov
Copy link

codecov bot commented Jan 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 53.17%. Comparing base (99223a8) to head (e7a3298).
⚠️ Report is 2 commits behind head on develop.

@@           Coverage Diff            @@
##           develop    #1256   +/-   ##
========================================
  Coverage    53.17%   53.17%           
========================================
  Files          394      394           
  Lines        11496    11496           
========================================
  Hits          6113     6113           
  Misses        4841     4841           
  Partials       542      542           
Flag Coverage Δ
unittests 53.17% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pkg/heartbeat/language.go 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gandarez gandarez mentioned this pull request Jan 8, 2026
@alanhamlett alanhamlett mentioned this pull request Jan 14, 2026
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