Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue #1178] Added hook to register content type and highlighting in orion #1392

Merged
merged 2 commits into from
Jun 2, 2016

Conversation

svenefftinge
Copy link
Contributor

@svenefftinge svenefftinge commented May 31, 2016

Fixes #1178.
With this change you can configure arbitrary new contentTypes and corresponding highlight configuration.
Here's a usage example:

@Inject
    protected void configureContentType(final OrionContentTypeRegistrant contentTypeRegistrant) {
        // register content type and configure orion
        final String contentTypeId = "text/x-testlang";

        OrionContentTypeOverlay contentType = OrionContentTypeOverlay.create();
        contentType.setId(contentTypeId);
        contentType.setName("Test Language");
        contentType.setExtension("testlang");
        contentType.setExtends("text/plain");

        // highlighting
        OrionHighlightingConfigurationOverlay config = OrionHighlightingConfigurationOverlay.create();
        config.setId("testlang.highlighting");
        config.setContentTypes(contentTypeId);
        config.setPatterns(
                "[\n" + 
                        "  {include: \"orion.lib#string_doubleQuote\"},\n" + 
                        "  {include: \"orion.lib#string_singleQuote\"},\n" + 
                        "  {include: \"orion.lib#brace_open\"},\n" + 
                        "  {include: \"orion.lib#brace_close\"},\n" + 
                        "  {include: \"orion.lib#bracket_open\"},\n" + 
                        "  {include: \"orion.lib#bracket_close\"},\n" + 
                        "  {include: \"orion.lib#parenthesis_open\"},\n" + 
                        "  {include: \"orion.lib#parenthesis_close\"},\n" + 
                        "  {include: \"orion.lib#number_decimal\"},\n" + 
                        "  {include: \"orion.lib#number_hex\"},\n" + 
                        "  {\n" + 
                        "    match: \"\\\\b(?:false|true)\\\\b\",\n" + 
                        "    name: \"keyword.json\"\n" + 
                        "  }\n" + 
                "]");

        contentTypeRegistrant.registerFileType(contentType, config);
    }

…hlighting configuration for Orion editor.

Signed-off-by: Sven Efftinge <sven.efftinge@typefox.io>
@codenvy-ci
Copy link

Can one of the admins verify this patch?

@evidolob
Copy link
Contributor

LGTM, @vparfonov ?

import com.google.inject.Inject;
import com.google.inject.Provider;

public class OrionContentTypeRegistrant {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing javadoc, author

@vparfonov
Copy link
Contributor

ok, @azatsarynnyy ?

@azatsarynnyy
Copy link
Member

ok

@vparfonov vparfonov merged commit d6a79e7 into eclipse-che:master Jun 2, 2016
akurinnoy pushed a commit that referenced this pull request Jun 6, 2016
… orion (#1392)

* [Issue #1178] Added hooks to register content type and highlighting configuration for Orion editor.
* [#1178] added some javadoc

Signed-off-by: Sven Efftinge <sven.efftinge@typefox.io>
@lgas
Copy link

lgas commented Aug 10, 2016

@svenefftinge Sorry to reopen but i can t figure out where I m suppose to use this snippet ?

@lgas
Copy link

lgas commented Aug 11, 2016

Ok, got it.
For those who wonders, you can just paste this function in your editor extension. That' s it.

@SharkJ
Copy link

SharkJ commented Nov 12, 2018

Hi,
How can I use this to add syntax coloring support to a new file type I added to Che? Can anyone kindly explain? It is not yet included in the Che doc, so I have no clue how I should use this with Che.

Thank you!

@SharkJ
Copy link

SharkJ commented Nov 15, 2018

Ok, got it.
For those who wonders, you can just paste this function in your editor extension. That' s it.

Hi,
To which file did you add this code snippet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow configuration of syntax highlighting
8 participants