Now I have configured Ace to work within my editor so It’s time to add the feature of Syntax Highlighter.
Generally, we’ll manually set mode to editor like
for this File extension must be known to us so that we can manually add mode but we don’t know the file extension before hand. so we have to use some intermediator which will tell the file extension.
Ace editor already have a built-in functionality
now How we can use it?
1. Initialize modelist
var modelist = ace.require("ace/ext/modelist");
2. Get the mode for particular file
var mode = modelist.getModeForPath(path).mode;
3. Set the mode to editor