Groovy-Emacs-Modes / groovy-emacs-modes

A groovy major mode, grails minor mode, and a groovy inferior mode.
84 stars 39 forks source link

Indent Spock blocks #13

Closed mitc0185 closed 7 years ago

mitc0185 commented 9 years ago

I will freely admit I am new to both Groovy and Spock, and not enough of an Emacs hacker to take this on alone.

When I'm writing spock in groovy mode, the blocks (given, when, then, etc...) are not being indented in the same way that other statements would be.

Example:

class ResourceOwnerPasswordCredentialsSpec extends Specification {

  def "Ability to get access token with valid client and user credentials"() {

  given:
  def http = new HTTPBuilder('https://gdmlx0016.hq.bigcompany.com:8445')
  http.ignoreSSLIssues()

  def postBody = [grant_type: 'password', username: 'person.alluri@bigcompany.com', password: 'password123']

  when:
  def resp = http.post( path : '/oauth/token', body: postBody, headers: [ Authorization: 'Basic OGFiNjJhOWMtMWI4Ni00ZDJhLTlkNGItMTUwODJiYzNmMDA0OjNpSnRQamVNdkk='] )

  then:
  resp.access_token.size() == 103

  } 
}

If I highlight all of that code and hit tab, the "given:" line does not tab in. I would expect that it would. If I put a regular statement above that line, it does get indented.

class ResourceOwnerPasswordCredentialsSpec extends Specification {
  def "Ability to get access token with valid client and user credentials"() {

    def indentationIsWorkingHere = true

  given:
  def http = new HTTPBuilder('https://gdmlx0016.hq.bigcompany.com:8445')
  http.ignoreSSLIssues()

  def postBody = [grant_type: 'password', username: 'person.alluri@bigcompany.com', password: 'password123']

  when:
  def resp = http.post( path : '/oauth/token', body: postBody, headers: [ Authorization: 'Basic OGFiNjJhOWMtMWI4Ni00ZDJhLTlkNGItMTUwODJiYzNmMDA0OjNpSnRQamVNdkk='] )

  then:
  resp.access_token.size() == 103

  } 
}

Is this something I can fix in my .emacs file? Or is the mode not catching this type of line? When I look at other examples of spock tests I'm seeing these lines indented.

russel commented 9 years ago

I think there is a problem with the default style rules. My personal set up is so amended from the default, I am seeing much more weird (wrong) stuff ;-)

russel commented 7 years ago

We have changed the Groovy mode from being a CC-Mode derived one to being a standalone one. We are therefore closing all issues relating to the old mode. If you try the new mode and see any problems please post a new issue.