Mode Plugin - Custom Syntax Highlighters


#1

Edit: For some reason you cannot post a post on c9 with more than 1 image / link on… For this reason I posted the question with pictures and links onto github. See here:


Hi All,

So we, my friend and I, are working in a markup language we have created (Documentation Markup Language).
You can find the C9 Syntax highlighter here: -snip-.

I noticed recently that you can add plugins to C9.io and a few days ago I found the SDK -snip-.

This leads me to believe that we can use C9 plugins to implement custom syntax highlighters into C9. However there are no examples that I have found of template plugins which implement syntax highlighters

Over the past few days I have been struggling to get this working… If I go to:

my/c9/workspace?debug=2

I have a plugin named “abap2” (i figured to start off with that I’d just use a syntax highlighter already present in ace, as this should be easy to implement (or so I thought…))

-snip-

At the top of abap2.js I have the following:

-snip-

So as far as I can tell this makes sense. We have abap2.js which has the correct first line, apab2.js requires abap_highlight_rules and everything should follow from there.

When running the plugin in the IDE, if I swap to a file “myFile.abap2”, the syntax highlighter is selected from the syntaxes list, however no highlighting is present:

-snip-

So here I am a bit clueless as to why this isn’t working… Has anyone managed to get custom modes to work in C9? Or are there any existing templates?

Thanks,
~Sancarn


#2

hi, are there any errors shown in the browser console?
Could you share your workspace with me, it will make finding the issue easier.


#3

Hi there @harutyun,

There are no errors in the browser console (that I can see), no.

I have added you to the workspace.

Thanks for the help :slight_smile:

Edit: Actually, tell a lie, there are some errors it seems:

Failed to load resource: the server responded with a status of 403 (Forbidden)
static.c9.io/nc-3.1.4094-ea37d9f2/config/workspace-html5.js:7230 [OT] Joined /myFile.abap2
api-iam.intercom.io/messenger/web/ping Failed to load resource: the server responded with a status of 403 (Forbidden)
range.js:1 Uncaught SyntaxError: Unexpected identifier
text.js:1 Uncaught SyntaxError: Unexpected identifier
oop.js:1 Uncaught SyntaxError: Unexpected identifier
lang.js:1 Uncaught SyntaxError: Unexpected identifier
abap_highlight_rules.js:103 Uncaught TypeError: Cannot read property ‘inherits’ of null
at Object.factory (abap_highlight_rules.js:103)
at activateModule (static.c9.io/nc-3.1.4094-ea37d9f2/config/workspace-html5.js:85)
at lookup (static.c9.io/nc-3.1.4094-ea37d9f2/config/workspace-html5.js:96)
at _require (static.c9.io/nc-3.1.4094-ea37d9f2/config/workspace-html5.js:97)
at req (static.c9.io/nc-3.1.4094-ea37d9f2/config/workspace-html5.js:76)
at Object.factory (abap2.js:6)
at activateModule (static.c9.io/nc-3.1.4094-ea37d9f2/config/workspace-html5.js:85)
at lookup (static.c9.io/nc-3.1.4094-ea37d9f2/config/workspace-html5.js:96)
at Array.map ()
at _require (static.c9.io/nc-3.1.4094-ea37d9f2/config/workspace-html5.js:103)

However reloading the plugin doesn’t cause the errors…


#4

the issue was caused by a wrong path in require.
Modes in ace can do require("../lib/oop"), because they are inside ace folder
Modes in other locations have to use require("ace/lib/oop") instead, i have updated this in your workspace, and everything seems to work now.


#5

Ah ha! That’s such a simple fix which is great! :slight_smile: Thank you so much for the help! I’ll upload the plugin example to github and will link it here so others have a place to start also. :slight_smile: