Add google-java-format support for java
google-java-format is a program that reformats Java source code to comply with Google Java Style, which is widely used by developers.
if it's ok, I will submit a PR.
PRs are always welcome.
Thanks!
I suggest the existing custom formatter configuration for this issue, as the google formatter is a jar file, which needs to be invoked via java command under an arbitrary filepath. The following neoformat configuration does add the google formatter to neoformat.
let g:neoformat_java_google = {
\ 'exe': 'java',
\ 'args': ['-jar /path/to/google-java-format.jar -'],
\ 'stdin': 1,
\ }
let g:neoformat_enabled_java = ['google']
@icearith yeah, this formatter should be custom by user themselfs.
Expecting each user to self-define formatter for google-java-format is not user-friendly. I see two solutions:
a) expecting user to provide own shell wrapper around command (I use Arch Linux and AUR package comes with google-java-format command on path)
b) introducing global variable pointing to jar file, like so:
let g:neoformat_java_google = {
\ 'exe': 'java',
\ 'args': ['-jar' . g:neoformat_java_google_jar . ' -'],
\ 'stdin': 1,
\ }
Of course, formatter would be defined only if variable is set.