Phil
Phil

Reputation: 50406

How do I add a new language syntax to Monaco editor?

I added my language and followed the instructions here to build https://github.com/Microsoft/monaco-languages

npm run prepublish

This outputs a release folder with dev, esm and min folders inside, but what to do with this output to add it to the Monaco editor?

Upvotes: 3

Views: 5212

Answers (1)

masfrost
masfrost

Reputation: 132

If you just want to test things out:

~$ git clone https://github.com/Microsoft/monaco-editor
~$ cd monaco-editor
~/monaco-editor$ npm install .
~/monaco-editor$ npm run simpleserver

Just make sure monaco-editor and monaco-languages (or any other plugins) are under the same directory.

If you want to create your own release then you can simply edit https://github.com/Microsoft/monaco-editor/blob/master/metadata.js#L68-L70 to point to your monaco-languages. I guess you could also update the package.json to install your own version of monaco-languages, or simple copy over your ~/monaco-languages/release folder to ~/monaco-editor/node_modules/monaco-languages/.

After that just ~/monaco-editor$ npm run release and you'll get your release folder.

Upvotes: 3

Related Questions