Skip to content

Commit 98705f6

Browse files
committed
feat(diff/syntax-highlight): add Elixir language support
Add community provided Elixir language parser to the utils/diffParsing module, allowing syntax highlighting of `*.ex` and `*.exs` files in diffs. Changes: - Install `codemirror-lang-elixir` package as a dependency. - Add Elixir file extension detection in `parserFromExtension`.
1 parent 35a2bd7 commit 98705f6

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

packages/ui/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"@types/postcss-pxtorem": "^6.1.0",
6666
"@vitest/browser": "catalog:",
6767
"autoprefixer": "^10.4.21",
68+
"codemirror-lang-elixir": "^4.0.0",
6869
"codemirror-lang-hcl": "^0.1.0",
6970
"cpy-cli": "^5.0.0",
7071
"cssnano": "^7.1.0",

packages/ui/src/lib/utils/diffParsing.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { toml } from '@codemirror/legacy-modes/mode/toml';
2929
import { NodeType, Tree, Parser } from '@lezer/common';
3030
import { tags, highlightTree } from '@lezer/highlight';
3131
import { nix } from '@replit/codemirror-lang-nix';
32+
import { elixir } from 'codemirror-lang-elixir';
3233
import { hcl } from 'codemirror-lang-hcl';
3334
import diff_match_patch from 'diff-match-patch';
3435
import type { BrandedId } from '$lib/utils/branding';
@@ -277,6 +278,10 @@ export function parserFromExtension(extension: string): Parser | undefined {
277278
case 'h++':
278279
return cpp().language.parser;
279280

281+
case 'ex':
282+
case 'exs':
283+
return elixir().language.parser;
284+
280285
case 'go':
281286
return go().language.parser;
282287

pnpm-lock.yaml

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)