add google-java-format fixer
This commit is contained in:
parent
fcfd1025cc
commit
0700c2d900
6 changed files with 76 additions and 1 deletions
|
@ -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.
|
||||
|
|
23
autoload/ale/fixers/google_java_format.vim
Normal file
23
autoload/ale/fixers/google_java_format.vim
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue