19

I'm developing with WebStorm. I want to have syntax highlighting for Jenkins Groovy pipelines.

It's possible to use InteliJ IDEA for editing Jenkinsfiles, but it's obviously inconvenient to switch back and forth between IDEs.

Can I install Groovy plugin from IntelliJ IDEA Community Edition in WebStorm? If yes - how?

Ginden
  • 5,149
  • 34
  • 68
  • Did you have a look at the plugin manager? Do you find it in there? – Vampire Oct 13 '17 at 10:51
  • 2
    Most likely not -- as it has dependencies on specific API/Java support that is not available in WebStorm and requires IntelliJ. If plugin is not listed in `Plugins | Browse repositories...` then it means it's either incompatible (not satisfying the dependency) or not published there. Considering that it's JetBrains' own plugin ... the 2nd option is not the case. – LazyOne Oct 13 '17 at 11:09

1 Answers1

26

I didn't get that plugin to work either, but as a partial alternative, you can use this TextMate bundle: https://github.com/textmate/groovy.tmbundle

  1. Download the repository (https://github.com/textmate/groovy.tmbundle/archive/master.zip)
  2. Extract the zip file to some directory on your system
  3. In WebStorm / IntelliJ / etc., go to File > Settings > Editor > TextMate bundles, click on the + sign and point it to the directory you just extracted to
rkok
  • 1,047
  • 14
  • 17
  • Can you share a detail steps for that? I clicked the link you provided but didn't find anything to download. – Jeff Tian Dec 05 '18 at 06:18
  • 1
    Hi Jeff, I made the instructions more detailed as you requested – rkok Dec 05 '18 at 08:01
  • Thank very much. Imported. Then how can I apply them to the Jenkinsfile then? – Jeff Tian Dec 05 '18 at 08:19
  • 4
    You have to manually add Jenkinsfile as an extension in the TextMate bundle source. See `/Syntaxes/Groovy.tmLanguage`, after line 8. Here's Jetbrains' own documentation regarding this: https://www.jetbrains.com/help/webstorm/importing-textmate-bundles.html – rkok Dec 05 '18 at 12:56
  • Thank you very much for your help! Do you know why there is no "Files supported via TextMate bundles" among the "recognized files types" dialog in my webstorm? – Jeff Tian Dec 06 '18 at 05:57
  • You're welcome! Not sure about that one; I don't see it either. Could be a bug, a removed feature or a new feature that hasn't been released yet. – rkok Dec 06 '18 at 07:39
  • 6
    Yes it does! That file types dialog entry is not strictly necessary. By default, after importing the TextMate bundle, it'll highlight `.groovy` and `.gvy` files. By adding a `Jenkinsfile` entry to the file mentioned earlier and then reimporting the bundle you can make it highlight files named `Jenkinsfile`. – rkok Dec 06 '18 at 11:48
  • 2
    Thank you again! Highlighting works! It would be better if it can fold/unfold the code blocks. – Jeff Tian Jan 09 '19 at 03:09
  • If you are using a non-default theme, while you are in File > Settings > Editor > TextMate bundles, you'll need to map the new theme. And it will not take effect until you restart the IDE. – talyric Apr 05 '19 at 19:00
  • 1
    WebStorm now officially supports Groovy via the TextMate Plugin, see [issue WEB-43111](https://youtrack.jetbrains.com/issue/WEB-43111). So, there's no need anymore for an additionally download like instructed above. – biolauri Nov 28 '21 at 17:40