Linguist: CodeMirror new external modes (abap)

Created on 27 Sep 2016  路  14Comments  路  Source: github/linguist

Dear GitHub,
It looks like the default web editor on GitHub has been changed to CodeMirror, this breaks the ABAP syntax highlighting while in edit mode :cry:

It looks like the CodeMirror project does not accept new modes, see https://github.com/codemirror/CodeMirror/pull/4245 (and other 'new mode' PRs).

I have already built a CodeMirror ABAP syntax highlighting mode, see https://github.com/larshp/codemirror-abap and published to npm as recommended by the CodeMirror author.
Are there any plans for GitHub to support CodeMirror modes which are not part of the main CodeMirror distribution?

Most helpful comment

yeah, though I'm not really sure how it would work, as it has to work together with the editor on the GitHub website, which seems not to be part of linguist.

Been thinking of using submodules, however I guess it would add a lot of noise to the linguist project, with stuff that is not really part of the linguist core functionality.

Depending on the build process, I think we also need to consider security, just adding code from a lot of different NPM packages into somewhere on GitHub might be bad.

Perhaps create a new governed project called something like 'github-codemirror-extra-modes', where people can add custom modes? And then use modes from that project in linguist?

just some thoughts...

All 14 comments

/ cc @tberman @josh

Hmmm, @josh this seems super reasonable, we would have to figure out the build process bits to make it easy to add new modes.

@larshp, a PR to linguist adding the support is definitely the first step.

yeah, though I'm not really sure how it would work, as it has to work together with the editor on the GitHub website, which seems not to be part of linguist.

Been thinking of using submodules, however I guess it would add a lot of noise to the linguist project, with stuff that is not really part of the linguist core functionality.

Depending on the build process, I think we also need to consider security, just adding code from a lot of different NPM packages into somewhere on GitHub might be bad.

Perhaps create a new governed project called something like 'github-codemirror-extra-modes', where people can add custom modes? And then use modes from that project in linguist?

just some thoughts...

Just curious, what prompted the switch from Ace to CodeMirror?

Been thinking of using submodules, however I guess it would add a lot of noise to the linguist project, with stuff that is not really part of the linguist core functionality.

That's already what we're doing for grammars, so it would probably be okay.

Depending on the build process, I think we also need to consider security, just adding code from a lot of different NPM packages into somewhere on GitHub might be bad.

It probably depends on what these external modes can do. If they are limited to syntax highlighting (as the grammars), that should be okay. If they can do more than change CSS styles (as the AsciiDoctor rendering engine), then they'll need security reviews :scream:

modes are just pieces of JS code that implements a specific "interface", see eg. https://github.com/codemirror/CodeMirror/blob/master/mode/turtle/turtle.js

I guess they can easily access window or document, and all the other things in javascript

So I think GitHub or anyone else's usage of the data linguist provides is fairly orthogonal.

As long as the codemirror mode exists, it would be good to have linguist properly expose that data. And then it would be up to any consumer to utilize it.

Depending on the build process, I think we also need to consider security, just adding code from a lot of different NPM packages into somewhere on GitHub might be bad.

That was on my mind as well, thanks for bringing it up.

Perhaps create a new governed project called something like 'github-codemirror-extra-modes', where people can add custom modes? And then use modes from that project in linguist?

Yeah! I really love this idea. We could be pretty liberal with commit access and give it to any maintainer that is willing to help out. That'd just mean one npm package for us to upgrade, review and deploy. Ensuring a consistent package directory layout would work best with our mode lazy loading techniques. And more eyes on the same repo (rather than a dozen) would help the security review angle as well.

Thinking of calling it github/codemirror-contrib, sound good? I can make it now.

Sounds good to me, it is not perfect, but it allows a way for people to add new modes for use on GitHub. I guess there will be more examples of new/small languages which does not have a mode in the main CodeMirror distribution in the future.

Perhaps it would make sense to have it as part of the CodeMirror organization, but judging from the CodeMirror PRs the probability seems low(@marijnh). It would also be possible to transfer the ownership if needed.

Perhaps it would make sense to have it as part of the CodeMirror organization

Yeah, I'd love to see that happen if possible. Maybe its something we can propose down the road.

closing issue, work continuing in https://github.com/github/codemirror-contrib

@larsbrinkhoff So for getting editing support for another language which is not in CodeMirror main, I do a PR at https://github.com/github/codemirror-contrib and then make a PR here for adding codemirror_mode and codemirror_mime_type to https://github.com/github/linguist/blob/master/lib/linguist/languages.yml?

afaik, it was never activated, currently the ABAP mode is not active on github.com

@larshp Thanks for the clarification.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

philiparvidsson picture philiparvidsson  路  4Comments

TimothyGu picture TimothyGu  路  5Comments

oldmud0 picture oldmud0  路  6Comments

etc0de picture etc0de  路  5Comments

haskellcamargo picture haskellcamargo  路  3Comments