atom-beautify icon indicating copy to clipboard operation
atom-beautify copied to clipboard

Support for Groovy

Open rgcruz010 opened this issue 9 years ago • 24 comments

Atom Beautify could not determine a supported beautifier to handle this file with grammar "Groovy" and extension "groovy"

rgcruz010 avatar May 27 '15 16:05 rgcruz010

I will need a beautifier that supports Groovy. If you have one, let me know.

A quick search turned up: https://github.com/spidasoftware/format

Glavin001 avatar May 27 '15 18:05 Glavin001

Is there any way to vote for this ticket? I also need Groovy beautifier for Atom.

arjangch avatar Aug 11 '15 14:08 arjangch

Is anyone working on that? I could try to take a look at it.

biancarosa avatar Sep 02 '15 16:09 biancarosa

@biancarosa I am not working on this currently. Please feel free to submit a Pull Request. If you have any questions, let me know. Thank you!

I'd recommend reading https://github.com/Glavin001/atom-beautify/blob/master/docs/add-languages-and-beautifiers.md

Glavin001 avatar Sep 03 '15 13:09 Glavin001

:+1:

jachin avatar Feb 18 '16 20:02 jachin

+1 vote from me

nilsmagnus avatar Mar 18 '16 12:03 nilsmagnus

I'd like Groovy support as well :)

SolveSoul avatar Dec 16 '16 07:12 SolveSoul

Approaching 2 years of being open... :/

stramel avatar Mar 02 '17 23:03 stramel

Sorry, I said I would take a look but in the end I couldn't.

Maybe someone else wants to give it a try?

Em qui, 2 de mar de 2017 20:28, Michael Stramel [email protected] escreveu:

Approaching 2 years of being open... :/

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Glavin001/atom-beautify/issues/371#issuecomment-283816285, or mute the thread https://github.com/notifications/unsubscribe-auth/ABaXbnoTcuB5jHZXF6CxMg78PtHM6zYaks5rh1BugaJpZM4EsJfI .

biancarosa avatar Mar 03 '17 00:03 biancarosa

Groovy and Gradle support to be specific. Thanks.

kevintanhongann avatar Mar 25 '17 05:03 kevintanhongann

We need to find a suitable third-party beautifier for Groovy/Gradle. Looks like https://github.com/spidasoftware/format is no longer maintained. For all Groovy/Gradle users, please search for and test different beautifiers. When you find one, post a link here, and create a Pull Request to integrate with Atom-Beautify. Let me know if you have any questions!

Glavin001 avatar Apr 09 '17 20:04 Glavin001

Any chance you could pull from https://github.com/groovy/groovy-eclipse/tree/master/ide/org.codehaus.groovy.eclipse.refactoring?

stramel avatar Apr 09 '17 21:04 stramel

@stramel generally we aim for either a Node.js implementation of a beautifier, or worst case is a beautifier we can execute from command-line. I'm not familiar with Groovy so I'll leave this research up to you and others. If you are able to do something like groovy --format --file FILE_NAME to beautify the file then Atom-Beautify will be able to support it 👍 .

Glavin001 avatar Apr 09 '17 21:04 Glavin001

Anyone else here because they write Jenkins pipeline scripts aka the Jenkinsfile ?

instantchow avatar Nov 08 '17 23:11 instantchow

Plus 1! Please add support for Jenkinsfile

bgiorgini avatar Nov 28 '17 18:11 bgiorgini

This will be very useful for those of us who writes groovy script and shared libraries to extend Jenkins functionalities or pipelines

ghost avatar Mar 15 '18 11:03 ghost

Groovy is not much different from javascript. It won't be wrong to say that json version comes in square brackets in it [key: value, nest : [nnest: [a1,a2,a3]]].

Is there a way to ask 'Beautify' to treat *.groovy as *.js and do it's job? @Glavin001

saurabh-sp-tripathi avatar May 25 '18 22:05 saurabh-sp-tripathi

Well I have a workaround (which could be considered solution IMO). @Glavin001 Do as following:

  • Packages -> Atom-Beautify -> settings -> 'View code'
  • Open file(ctrl+B: javascript.coffee) : /.atom/packages/atom-beautify/javascript.coffee
  • Find array 'extensions' //it's line:17 right now.
  • add "groovy" to it
  • You are done!!! :smiley: njoy
 ###
  Supported extensions
  ###
  extensions: [
    "js",
    "groovy"
  ]

****************************** EDIT : Better solution ******************************************** Follow the link to atom treat groovy file as js https://discuss.atom.io/t/how-do-i-make-atom-recognize-a-file-with-extension-x-as-language-y/26539

saurabh-sp-tripathi avatar May 25 '18 23:05 saurabh-sp-tripathi

@saurabh-sp-tripathi : In the past 11 days of usage, have you found treating Groovy files as JavaScript has worked well? If so, please feel free to submit a Pull Request. Recommended reading: https://github.com/Glavin001/atom-beautify/blob/master/docs/add-languages-and-beautifiers.md

Glavin001 avatar Jun 06 '18 00:06 Glavin001

@Glavin001 I think that might not be needed, a better solution would be this - https://discuss.atom.io/t/how-do-i-make-atom-recognize-a-file-with-extension-x-as-language-y/26539

note: take care cson format, it didn't work at first when I identified that i have placed my config in wrong place

saurabh-sp-tripathi avatar Jun 06 '18 21:06 saurabh-sp-tripathi

TIP If you don't want to change configuration, open Command Palette and type "beautify javascript".

ezh avatar Aug 19 '18 16:08 ezh

I attempted reformatting an entire baseline using the Javascript formatter, and while it did get me to the end goal, it's not perfect. JS formatter leaves a few groovy-isms in a bad state:

... { x -> becomes

... {
  x - > 

object?.attribue becomes object ? .attribute test ?: value becomes test ? : value variable ==~ /regex/ becomes variable == ~/regex (The most insidious one, because it compiles but behaves differently!)

There might have been a few more.. but the bottom line was those kinds of special operators added spacing that made code not compile. So, if you're willing to check those after running the JS beautifier, then - go for it!

aztechian avatar Oct 10 '18 18:10 aztechian

I would also appreciate Groovy/Gradle support, but i have to say, abusing the JavaScript beautifier works remarkably well. Great hack, @saurabh-sp-tripathi!

tomwhoiscontrary avatar Mar 15 '19 16:03 tomwhoiscontrary

Well I have a workaround (which could be considered solution IMO). @Glavin001 Do as following:

* Packages -> Atom-Beautify -> settings -> 'View code'

* Open file(ctrl+B: javascript.coffee) : /.atom/packages/atom-beautify/javascript.coffee

* Find array 'extensions' //it's line:17 right now.

* add "groovy" to it

* You are done!!! smiley njoy
 ###
  Supported extensions
  ###
  extensions: [
    "js",
    "groovy"
  ]

****************************** EDIT : Better solution ******************************************** Follow the link to atom treat groovy file as js https://discuss.atom.io/t/how-do-i-make-atom-recognize-a-file-with-extension-x-as-language-y/26539

Unfortunately, the link in your comment was dead, but it pointed me in the right direction.

To use the JavaScript beautifier without modifying javascript.coffee, I did the following:

  • Installed the file-types package
  • Added the following to the Atom config.cson file (Command Palette -> Application: Open Your Config or Edit -> Config) under "*": "file-types": "*.gradle": "source.js"

I tried achieving the same using built-in Custom Language Recognition, but wasn't able to get it working.

Hope this helps!

Patrick-Sutton avatar Aug 25 '21 23:08 Patrick-Sutton