forked from nodejs/nodejs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shiki.config.mjs
68 lines (65 loc) · 2.33 KB
/
shiki.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
'use strict';
/**
* READ: Vercel's NFT is unable to by default understand that a dependent package (`shiki`) loads any of the files
* mentioned within `BUNDLED_LANGUAGES` as they're loaded on-demand. We circumvent this issue by manually declaring these languages
*
* NOTE: Shiki attempts to load matching Languages from their `BUNDLED_LANGUAGES` by the built-in provided paths, even if we provide
* languages with a custom `path`. This would cause issues with Vercel's NFT as it doesn't recognise the need of these files.
*
* This is easily fixable by using `require.resolve` on the languages below which makes Vercel NFT aware of these files.
* Yet instead we adopted the `grammar` property approach instead of `path`, since if a `grammar` field is provided, it allows
* Shiki to load the ones we provide instead of the ones from `BUNDLED_LANGUAGES`.
*/
import cLanguage from 'shiki/languages/c.tmLanguage.json' assert { type: 'json' };
import cppLanguage from 'shiki/languages/cpp.tmLanguage.json' assert { type: 'json' };
import javaScriptLanguage from 'shiki/languages/javascript.tmLanguage.json' assert { type: 'json' };
import jsonLanguage from 'shiki/languages/json.tmLanguage.json' assert { type: 'json' };
import jsxLanguage from 'shiki/languages/jsx.tmLanguage.json' assert { type: 'json' };
import typeScriptLanguage from 'shiki/languages/typescript.tmLanguage.json' assert { type: 'json' };
import xmlLanguage from 'shiki/languages/xml.tmLanguage.json' assert { type: 'json' };
import yamlLanguage from 'shiki/languages/yaml.tmLanguage.json' assert { type: 'json' };
/** @type {import('shiki').ILanguageRegistration[]} */
export const SUPPORTED_LANGUAGES = [
{
id: 'c',
scopeName: 'source.c',
grammar: cLanguage,
},
{
id: 'cpp',
scopeName: 'source.cpp',
grammar: cppLanguage,
},
{
id: 'javascript',
scopeName: 'source.js',
aliases: ['js'],
grammar: javaScriptLanguage,
},
{
id: 'json',
scopeName: 'source.json',
grammar: jsonLanguage,
},
{
id: 'jsx',
scopeName: 'source.js.jsx',
grammar: jsxLanguage,
},
{
id: 'typescript',
scopeName: 'source.ts',
aliases: ['ts'],
grammar: typeScriptLanguage,
},
{
id: 'xml',
scopeName: 'text.xml',
grammar: xmlLanguage,
},
{
id: 'yaml',
scopeName: 'source.yaml',
grammar: yamlLanguage,
},
];