Skip to content

Replace syntect defaults with two-face for expanded syntax highlighting#155

Merged
agavra merged 1 commit intoagavra:mainfrom
mikecfisher:feat/two-face-syntax-highlighting
Feb 8, 2026
Merged

Replace syntect defaults with two-face for expanded syntax highlighting#155
agavra merged 1 commit intoagavra:mainfrom
mikecfisher:feat/two-face-syntax-highlighting

Conversation

@mikecfisher
Copy link
Copy Markdown
Contributor

@mikecfisher mikecfisher commented Feb 7, 2026

Follow-up to #154.

That PR did a few things: it fixed the diff highlighting to split by old/new side (the old code fed interleaved lines through syntect's stateful parser), added per-line failure isolation so one bad line doesn't kill highlighting for the whole file, and included a block of fallback extension mappings to cover languages syntect doesn't ship with (ts -> js, toml -> yaml, kt -> java, etc.).

The first two changes are good and still in the codebase. But while working on the fallback mappings I realized the root problem wasn't missing mappings, it's that syntect's built-in syntax set only covers 40 languages. Mapping TypeScript to JavaScript isn't proper syntax highlighting

The two-face crate bundles the syntax and theme definitions from bat, which gives us ~170 languages natively — TypeScript, TSX, TOML, Dockerfile, Kotlin, Swift, Zig, Svelte, Vue, Elixir, and everything else that was in the fallback table. It returns the same syntect types, so the rest of the highlighting pipeline is untouched.

What changed:

  • SyntaxSet::load_defaults_newlines() -> two_face::syntax::extra_newlines()
  • ThemeSet::load_defaults() -> two_face::theme::extra()
  • SyntaxHighlighter::new() takes EmbeddedThemeName instead of &str (compile-time checked)
  • Removed the fallback extension mapping block since two-face covers all of those natively
  • Removed syntect-tui, which was never imported anywhere and was pulling in an old ratatui 0.28.1

The syntect crate itself stays — two-face wraps it, it doesn't replace it.

Test plan

  • cargo build compiles clean
  • cargo test — all 159 tests pass
  • Open a TypeScript/TSX diff and confirm native highlighting (not JS fallback)

@mikecfisher mikecfisher force-pushed the feat/two-face-syntax-highlighting branch from 7de9208 to 2d44a14 Compare February 7, 2026 00:44
…tax highlighting

Switch from syntect's built-in syntax/theme definitions to two-face,
which bundles bat's expanded sets (~170 languages). This adds native
highlighting for TypeScript, TSX, TOML, Dockerfile, Kotlin, and many
others — trimming the fallback extension table down to the few formats
two-face doesn't cover (jsx, mjs, handlebars, etc.). Also removes the
unused syntect-tui dependency.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@mikecfisher mikecfisher force-pushed the feat/two-face-syntax-highlighting branch from 2d44a14 to 59edc8a Compare February 7, 2026 00:53
Copy link
Copy Markdown
Owner

@agavra agavra left a comment

Choose a reason for hiding this comment

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

Thanks @mikecfisher :)

@agavra agavra merged commit f0bee18 into agavra:main Feb 8, 2026
4 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.

2 participants