cucumber / gherkin

A parser and compiler for the Gherkin language.
MIT License
191 stars 66 forks source link

Update Gherkin syntax highlighters to support Rule keyword #14

Open aslakhellesoy opened 5 years ago

aslakhellesoy commented 5 years ago

With the release of Gherkin 8 and Cucumbers using it, various syntax highlighters must be updated to support the new keywords.

A good start is to create issues in these tools' bug trackers. The issues should suggest using gherkin-languages.json to do code-generation. That way the lexers/parsers can be easily updated when new translations are added (or if we make other grammar changes in the future).

I have compiled a list of highlighters/editors below. Please add a comment with a link to the issue/PR if you create one and I will update this list. We'll check the box when an issue is fixed.

Which ones did I forget?

superseeker13 commented 5 years ago

Geany - The Flyweight IDE https://www.geany.org/

aslakhellesoy commented 5 years ago

Links to some of these editors/highlighters are here: https://cucumber.io/docs/tools/related-tools/

badeball commented 5 years ago

We also have rouge, which I believe is what powers Gitlab.

davidjgoss commented 5 years ago

IntelliJ support is done via https://youtrack.jetbrains.com/issue/IDEA-199579, I can confirm this is working in the current version (2019.3), and also in:

That's as far as I can confirm with what I have installed, but seems as though all the IDEA tools are covered by the same core plugin.

aslakhellesoy commented 5 years ago

I noticed that too @davidjgoss - impressive!

davidjgoss commented 5 years ago

Oh, so although the Gherkin syntax support (in terms of highlighting and formatting) is fine, the autocompletion is not quite there:

image

Looks like the autocompletion comes from a Cucumber plugin (as opposed to the Gherkin language support) as that's also what drives the autocompletion of steps and jumping between implementation and usage etc. Seems to live here https://github.com/JetBrains/intellij-plugins/tree/master/cucumber/src/org/jetbrains/plugins/cucumber, I might take a run at fixing it later.

aslakhellesoy commented 5 years ago

That would be great @davidjgoss!

I think the most important thing to fix in that plugin is to recognise cucumber expressions...

davidjgoss commented 5 years ago

Having looked deeper now, the main cucumber plugin for IDEA does support autocompletion of Rule etc but it's behind a isGherkin6Supported check which is down to the language-specific extension (java, groovy) to implement. Looking at other code it seems the intent would be to base this on the version of cucumber-jvm, which in turn it's deriving based on some heuristics around what it finds (or doesn't) on the classpath.

cucumber-jvm on master is currently on gherkin 5.2.0 but it would be nice to get the plugin primed so it just starts working as soon as people update to whatever version bring gherkin 6+ with it - maybe we can expose the gherkin version in version.properties that comes with the core jar, and then pick that up in the plugin?

aslakhellesoy commented 5 years ago

I think a better name than isGherkin6Supported would be isGherkinRuleKeywordSupported. We're already on Gherkin 8 now, and 9 is due soon. There aren't any grammar changes from 6 to 9, but the library's API has undergone some changes.

aslakhellesoy commented 4 years ago

There are a lot of third-party highlighters out there that people may want to send pull-requests to. In order to make it easy to send new pull requests whenever Gherkin changes, we need some utilities to make it easy to update them.

Take pygments for example.

We should provide some simple command-line tool (in gherkin/scripts) that can generate these strings so they can be pasted into a PR. For example:

./scripts/syntax-highlight-util --keywords given,when,then,and,but

Which could output something like this:

하지만|조건|먼저|만일|만약|단|그리고|그러면|那麼|那么|而且|當|当|前提|假設|假设|假如|假定|但是|但し|並且|并且|同時|同时|もし|ならば|ただし|しかし|かつ|و |متى |لكن |عندما |ثم |بفرض |اذاً |כאשר |וגם |בהינתן |אזי |אז |אבל |Якщо |Унда |То |Припустимо, що |Припустимо |Онда |Но |Нехай |Лекин |Когато |Када |Кад |К тому же |И |Задато |Задати |Задате |Если |Допустим |Дадено |Ва |Бирок |Аммо |Али |Але |Агар |А |І |Și |És |Zatati |Zakładając |Zadato |Zadate |Zadano |Zadani |Zadan |Youse know when youse got |Youse know like when |Yna |Ya know how |Ya gotta |Y |Wun |Wtedy |When y\'all |When |Wenn |WEN |Và |Ve |Und |Un |Thì |Then y\'all |Then |Tapi |Tak |Tada |Tad |Så |Stel |Soit |Siis |Si |Sed |Se |Quando |Quand |Quan |Pryd |Pokud |Pokiaľ |Però |Pero |Pak |Oraz |Onda |Ond |Oletetaan |Og |Och |O zaman |Når |När |Niin |Nhưng |N |Mutta |Men |Mas |Maka |Majd |Mais |Maar |Ma |Lorsque |Lorsqu\'|Kun |Kuid |Kui |Khi |Keď |Ketika |Když |Kaj |Kai |Kada |Kad |Jeżeli |Ja |Ir |I CAN HAZ |I |Ha |Givun |Givet |Given y\'all |Given |Gitt |Gegeven |Gegeben sei |Fakat |Eğer ki |Etant donné |Et |Então |Entonces |Entao |En |Eeldades |E |Duota |Dun |Donitaĵo |Donat |Donada |Do |Diyelim ki |Dengan |Den youse gotta |De |Dato |Dar |Dann |Dan |Dado |Dacă |Daca |DEN |Când |Cuando |Cho |Cept |Cand |Cal |But y\'all |But |Buh |Biết |Bet |BUT |Atès |Atunci |Atesa |Anrhegedig a |Angenommen |And y\'all |And |An |Ama |Als |Alors |Allora |Ali |Aleshores |Ale |Akkor |Aber |AN |A také |A |\\*