For server side code the OpenMRS code formatter is used.
The following are the steps for setting up Intellij Community edition to use the OpenMRS code formatter.
Get the OpenMRS Formatter XML file and save it on the local machine.
Go to File → Settings → Code Style → Java.
...
3. The default scheme is Default IDE . To change this click on the gear icon to the right of the default scheme.
4. On the drop down that appears click on Import Scheme.
5. Click on the Eclipse XML Profile option then import the OpenMRS formatter xml file downloaded in step one.
6. After a successful import the Scheme will now be showing OpenMRS Formatter.
...
7. Click on Apply.
8. Click on Ok.