summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2018-03-16 13:45:53 +0000
committerdakkar <dakkar@thenautilus.net>2018-03-16 13:45:53 +0000
commit0721ea567f4470cb0928c93f29b1b1f18ada620d (patch)
tree8b0bd7d118df1fe81a833b6d6c4cd084cc47eeed
parentadd elisp (diff)
downloadcolor-0721ea567f4470cb0928c93f29b1b1f18ada620d.tar.gz
color-0721ea567f4470cb0928c93f29b1b1f18ada620d.tar.bz2
color-0721ea567f4470cb0928c93f29b1b1f18ada620d.zip
hack to add "file extensions" to existing grammars
-rw-r--r--index.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/index.js b/index.js
index d9efb54..268753d 100644
--- a/index.js
+++ b/index.js
@@ -9,6 +9,20 @@ highlighter.requireGrammarsSync({
"modulePath": require.resolve('language-emacs-lisp/package.json'),
});
+const Selector = require('first-mate-select-grammar');
+const selector = Selector();
+function addExtensionsToGrammar(knownExtension,extraExtensions) {
+ let grammar = selector.selectGrammar(
+ highlighter.registry,
+ `some_file.${knownExtension}`,
+ "not much");
+ if (grammar) {
+ Array.prototype.push.apply(grammar.fileTypes,extraExtensions);
+ }
+}
+
+addExtensionsToGrammar('cpp',['ino']);
+
const server = http.createServer((req, res) => {
const filename = req.headers['filename'];
let buffer = '';