From 0721ea567f4470cb0928c93f29b1b1f18ada620d Mon Sep 17 00:00:00 2001 From: dakkar Date: Fri, 16 Mar 2018 13:45:53 +0000 Subject: hack to add "file extensions" to existing grammars --- index.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 = ''; -- cgit v1.2.3