Skip to content

Commit 8a4e4e0

Browse files
committed
Fix syntax highlighting for other language than lua
Other languages didn’t have syntax highlighting because our custom style is tailored specifically for Lua and might not include all necessary tags. That’s why we load the syntax from another theme (GitHub Dark) for other languages and override only the Lua language.
1 parent ea4a418 commit 8a4e4e0

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

web/ec.config.mjs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
1-
import fs from 'fs';
1+
import { readFileSync } from 'fs';
22

3-
export default {
4-
themes: [
5-
JSON.parse(fs.readFileSync('./src/themes/mtasa_lua-theme_dark.json', 'utf-8')),
6-
JSON.parse(fs.readFileSync('./src/themes/mtasa_lua-theme_light.json', 'utf-8')),
3+
import githubDark from 'tm-themes/themes/github-dark.json' with { type: 'json' };
4+
const mtaLuaDark = JSON.parse(readFileSync('./src/themes/mtasa_lua-theme_dark.json', 'utf-8'));
5+
6+
const hybridTheme = {
7+
...githubDark,
8+
tokenColors: [
9+
...githubDark.tokenColors,
10+
...mtaLuaDark.tokenColors,
711
],
12+
colors: [mtaLuaDark.colors]
13+
};
14+
15+
export default {
16+
themes: [hybridTheme],
817
shiki: {
918
langs: [
1019
{
1120
id: 'lua',
1221
scopeName: 'source.lua.mta',
13-
...JSON.parse(fs.readFileSync('./src/grammars/lua-mta.tmLanguage.json', 'utf-8')),
22+
...JSON.parse(readFileSync('./src/grammars/lua-mta.tmLanguage.json', 'utf-8')),
1423
},
1524
],
1625
},

web/package-lock.json

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"glob": "^11.0.2",
1919
"js-yaml": "^4.1.0",
2020
"marked": "^15.0.6",
21-
"sharp": "^0.32.5"
21+
"sharp": "^0.32.5",
22+
"tm-themes": "^1.10.6"
2223
},
2324
"optionalDependencies": {
2425
"@rollup/rollup-linux-x64-gnu": "*"

0 commit comments

Comments
 (0)