common icon indicating copy to clipboard operation
common copied to clipboard

Update Gherkin syntax highlighters to support Rule keyword

Open aslakhellesoy opened this issue 4 years ago • 10 comments

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.

  • [ ] Ace
  • [ ] CodeMirror
  • [ ] Emacs
  • [ ] Geany
  • [x] gherkin-lint
  • [ ] Highlight.js
  • [ ] IntelliJ IDEA
  • [ ] Prism.js
  • [ ] Pygments
  • [ ] Rainbow
  • [ ] SHJS
  • [ ] Source Highlight
  • [ ] SpecFlow.VisualStudio
  • [ ] SyntaxHighlighter
  • [ ] Vim
  • [x] Visual Studio Code
  • [ ] Sublime Text
  • [ ] TextMate
  • [ ] GitHub Pull Requests

Which ones did I forget?

aslakhellesoy avatar Oct 31 '19 12:10 aslakhellesoy

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

superseeker13 avatar Nov 05 '19 03:11 superseeker13

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

aslakhellesoy avatar Nov 06 '19 21:11 aslakhellesoy

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

badeball avatar Nov 09 '19 11:11 badeball

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:

  • WebStorm
  • GoLand
  • RubyMine

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.

davidjgoss avatar Dec 02 '19 14:12 davidjgoss

I noticed that too @davidjgoss - impressive!

aslakhellesoy avatar Dec 02 '19 15:12 aslakhellesoy

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.

davidjgoss avatar Dec 02 '19 15:12 davidjgoss

That would be great @davidjgoss!

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

aslakhellesoy avatar Dec 02 '19 16:12 aslakhellesoy

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?

davidjgoss avatar Dec 03 '19 15:12 davidjgoss

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 avatar Dec 03 '19 16:12 aslakhellesoy

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 |\\*

aslakhellesoy avatar Oct 20 '20 15:10 aslakhellesoy