If you want to add a new language to the site, you should follow this steps:
Add the new language to the exported languages
variable in lib/languages.ts
:
'language-key': { name: YOUR_LANGUAGE_DISPLAY_NAME, monaco: MONACO_MODE_ID, extensions: ARRAY_OF_FILE_EXTENSIONS_OF_YOUR_LANGUAGE, alias: [], // Leave empty unless needed, logoUrl: PATH_TO_LOGO, logoUrlDark: PATH_TO_DARK_LOGO, // Optional if not needed }
MonacoEditorWebpackPlugin
config in webpack.config.esm.js
static/modes/asm-mode.js
as an example. Don't forget to require your mode file in static/modes/_all.ts
, in alphabetical orderlanguage-key
is how your language will be referred internally by the code. In the rest of this document, replace {language-key}
by the corresponding value in the real files.views/resources/logos/
folder and add its path to the logoUrl{Dark}
key(s) in the language objectAdd a lib/compilers/{language-key}.js
file using the template below:
import {BaseCompiler} from '../base-compiler'; export class LanguageCompiler extends BaseCompiler { static get key() { return 'language'; } }
key
above corresponds to the compilerType
value in etc/config/{language-key}.defaults.properties
(Explained below). This is usually {language-key}
, but you can use whatever fits bestOptionsForFilter
method from the base classfs.remove(result.dirPath);
in base-compiler.js, so the latest CE compile attempt remains on disk for you to reviewinputFilename
outputFilename
is determined by the getOutputFilename()
methodOptionsForFilter()
and adding inputFilename
runCompiler()
method too. When overriding it, here are some ideasexecOptions.customCwd
parameter if the working directory needs to be somewhere elseexecOptions.env
parameter if the compiler requires special environment variablesoptions
, but make sure the user can still add their own arguments in CEAdd your LanguageCompiler
to lib/compilers/_all.js
, in alphabetical order
Add a etc/config/{language-key}.local.properties
file:
Add a new file etc/config/{language-key}.defaults.properties
. This is where a default configuration will live.
etc/config/c++.defaults.properties
for an example)Of important note, for both files, is to properly define compilerType
property in the newly added compilers. This should equal the value returned by your LanguageCompiler.key
function
Running make dev EXTRA_ARGS="--debug --language {language-key}"
to tell CE to only load your new language
You can check http://127.0.0.1:10240/api/compilers to be sure your language and compilers are there
Make an installer in the infra repository
Add your language files ({language-key}.*.properties
and lib/compilers/{language-key}.js
) to the list in .github/labeler.yml