uqbar-project / wollok

Wollok Programming Language
GNU General Public License v3.0
60 stars 16 forks source link

Add syntax highlighting to Mumuki editor for wollok #445

Closed javierfernandes closed 8 years ago

javierfernandes commented 8 years ago

On Wollok side I will create a small generic app that will generate what mumuki needs based on the xtext grammar, so that we don't need to manually maintain another file and apply changes every time we update the wollok grammar. I already know how to generate a list of wollok keywords dynamically.

I might also publish this as a separated tool for any xtext language, to contribute to xtext community, if the output is generic enough.

javierfernandes commented 8 years ago

@flbulgarelli @faloi what do you need for this ?

Where can I take a look for other examples of syntax highlight for other languages ?

flbulgarelli commented 8 years ago

Hi! We need support for Ace editor format, and Github Flavoured markdown format

javierfernandes commented 8 years ago

I guess that one needs to create a new Ace editor mode

https://github.com/ajaxorg/ace/wiki/Creating-or-Extending-an-Edit-Mode

Although Ace page says Sublime hightlight can be imported into Ace. We already have one of that

javierfernandes commented 8 years ago

Example custom ace mode for bash

https://github.com/flexiant/ace-mode-bash

faloi commented 8 years ago

Although Ace page says Sublime hightlight can be imported into Ace. We already have one of that

Here is the HOW-TO, updated on September 2012 :worried:. Can you give it a try?

javierfernandes commented 8 years ago

I created a new one based on Java's mode in Ace

screen shot 2015-11-19 at 16 49 30

It still requires manual work to maintain. And I had to copy paste java mode code which has a lot of code that I don't fully understand, but it works relatively well.

I need to:

faloi commented 8 years ago

See how Mumuki can use this mode (maybe I can create a PR for ace repo so that they can include wollok mode by default ?)

Yes, let's try that first. Modes are not pluggable, so to include it we have to fork many repositories (Ace, the gem that provides Ace on Rails, etc).

javierfernandes commented 8 years ago

rails :S

javierfernandes commented 8 years ago

Here is an example PR for drools

https://github.com/ajaxorg/ace/pull/2672

javierfernandes commented 8 years ago

Ok. I think that I already have it ready for creating a PR to ace. I was able to create a test and run it successfully.

I have also contributed with code snippets which allows to have a basic autocomplete !! Look !

screen shot 2015-11-20 at 14 12 13

@npasserini @faloi @flbulgarelli

To enabled this you should include this in mumuki html

<script src="/Users/jfernandes/dev/data/repo/wollok/ace-editor/wollok-ace/build/src/ace.js" type="text/javascript" charset="utf-8"></script>
<script src="/Users/jfernandes/dev/data/repo/wollok/ace-editor/wollok-ace/build/src/ext-language_tools.js" type="text/javascript" charset="utf-8"></script>

<script>
    var editor = ace.edit("editor");
    //editor.setTheme("ace/theme/monokai");
    editor.getSession().setMode("ace/mode/wollok");
    editor.setOptions({
        enableBasicAutocompletion: true
    });
</script>

(disregard my local path, the second js

javierfernandes commented 8 years ago

PR created https://github.com/ajaxorg/ace/pull/2776

flbulgarelli commented 8 years ago

Awesome

javierfernandes commented 8 years ago

PR closed !

https://github.com/ajaxorg/ace/pull/2776

flbulgarelli commented 8 years ago

Awesome!