add google-java-format fixer

This commit is contained in:
butlerx 2017-12-09 13:52:15 +00:00
parent fcfd1025cc
commit 0700c2d900
No known key found for this signature in database
GPG key ID: B37CA765BAA89170
6 changed files with 76 additions and 1 deletions

View file

@ -154,6 +154,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['sh'],
\ 'description': 'Fix sh files with shfmt.',
\ },
\ 'google_java_format': {
\ 'function': 'ale#fixers#google_java_format#Fix',
\ 'suggested_filetypes': ['java'],
\ 'description': 'Fix Java files with google-java-format.',
\ },
\}
" Reset the function registry to the default entries.

View file

@ -0,0 +1,23 @@
" Author: butlerx <butlerx@notthe,cloud>
" Description: Integration of Google-java-format with ALE.
call ale#Set('google_java_format_executable', 'google-java-format')
call ale#Set('google_java_format_use_global', 0)
call ale#Set('google_java_format_options', '')
function! ale#fixers#google_java_format#Fix(buffer) abort
let l:options = ale#Var(a:buffer, 'google_java_format_options')
let l:executable = ale#Var(a:buffer, 'google_java_format_executable')
if !executable(l:executable)
return 0
endif
return {
\ 'command': ale#Escape(l:executable)
\ . ' ' . (empty(l:options) ? '' : ' ' . l:options)
\ . ' --replace'
\ . ' %t',
\ 'read_temporary_file': 1,
\}
endfunction