Skip to content

feat: add TextMate grammar#332

Open
jack5github wants to merge 3 commits into
cucumber:mainfrom
jack5github:grammar
Open

feat: add TextMate grammar#332
jack5github wants to merge 3 commits into
cucumber:mainfrom
jack5github:grammar

Conversation

@jack5github

@jack5github jack5github commented Jun 11, 2026

Copy link
Copy Markdown

🤔 What's changed?

  • Added cucumber.tmLanguage.json which contains TextMate grammar rules for enhanced syntax highlighting and colour theme customisation.
  • Added scripts/update-grammar.js which updates cucumber.tmLanguage.json with all Gherkin language keywords and saves it to out/cucumber.tmLanguage.json (which is whitelisted in .vscodeignore).
  • Changed package.json's scripts to add update-grammar, which is run during npm run build, and to include the new TextMate grammar rules, as well as the embedded languages json, xml, yaml (VSCode in-built data serialisation languages) and markdown (commonly used to store large text).
  • Documentation updates

⚡️ What's your motivation?

The semantic highlighting that this VSCode extension currently supplies is insufficient when it comes to understanding feature files at a glance, as a lot of colour and font style customisations that could be applied to these files (e.g., heading styles, block comments, etc.) is absent. The most egregious example of this is feature, rule and scenario descriptions not standing out from step names.

🏷️ What kind of change is this?

  • ⚡ New feature (non-breaking change which adds new behaviour)

Example below (colour theme is 'Dark 2026'):

Screenshot of TextMate token colours

♻️ Anything particular you want feedback on?

  • The semantic highlighting this plugin already provides overrides the TextMate grammar rules, meaning colour customisations for tags and keywords are completely replaced while semantic highlighting is active, making it harder to control their underlying styles. I'd like to suggest that only variable values be covered by semantic highlighting, as they cannot be ascertained by TextMate grammar rules alone.
  • There may be edge cases with my regular expressions that I have failed to cover.
  • I wasn't able to figure out how to give only the first row of table cells a token that defines them as variable names. Then again, this may not be necessary depending on how the majority of testers use data tables.
  • I have chosen TextMate token names according to Language Grammars Naming Conventions, though these token names are still only my choices. I wouldn't mind suggestions for what the token names should be, as once they are committed into the main branch, it is unlikely they will be changed again.
  • Currently, only json, markdown, xml and yaml are supported as embedded languages in doc strings. This list may need to be expanded depending on the needs of testers. It would be very difficult to dynamically update this list.

📋 Checklist:

  • I agree to respect and uphold the Cucumber Community Code of Conduct
  • I've changed the behaviour of the code
    • I have added/updated tests to cover my changes. (This VSCode plugin has no automated tests to assess its functionality. I tested my changes through manual testing.)
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • Users should know about my change
    • I have added an entry to the "Unreleased" section of the CHANGELOG, linking to this pull request.

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.

1 participant