Overlay mode override keywords, atoms from original mode

I’m currently creating my own mode using the overlayMode api.
My mode is an overlay on existing “text/x-sql”. In my code I define this like :

    var myKeywords = "keyword1 keyword2 keyword3 ";


    CodeMirror.defineMode("dimensions", function (config, parserConfig) {
        var functions = parserConfig.keywords || {},

        var dimensionOverlay = {
            token: function (stream, state) {
                stream.eatWhile(/^["_\w\d]/);
                var word = stream.current().toLowerCase();

                if (functions.hasOwnProperty(word)) return "keyword"
                stream.next();
                return null;
            }
        };
        return CodeMirror.overlayMode(CodeMirror.getMode(config, parserConfig.backdrop || "text/x-sql"), dimensionOverlay);
    });


    CodeMirror.defineMIME("text/dimensions", {
        name: "dimensions",
        keywords: set(myKeywords),
    });

As you can see I am using my own set of keywords which I want stylized. However this also stylizes the keywords from “text/x-sql” mode (which is the expected behavior).

A possible solution for me is to edit the code in sql.js . However I want to avoid changes in 3rd party library for my project. Is there any better approach (maybe using something other than overlayMode) through which I can override the keywords in “text/x-sql” mode such that it only stylizes myKeywords.

Yes, look how the MIME types at the bottom of mode/sql/sql.js are defined — you can configure the set of keywords (and other options) in the mode config object.

Understood. Thanks a lot.