File: google_java_format.vim

package info (click to toggle)
vim-ale 4.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,764 kB
  • sloc: sh: 499; python: 311; perl: 31; makefile: 4; xml: 4; javascript: 1
file content (23 lines) | stat: -rw-r--r-- 812 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
" Author: butlerx <butlerx@notthe,cloud>
" Description: Integration of Google-java-format with ALE.

call ale#Set('java_google_java_format_executable', 'google-java-format')
call ale#Set('java_google_java_format_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('java_google_java_format_options', '')

function! ale#fixers#google_java_format#Fix(buffer) abort
    let l:options = ale#Var(a:buffer, 'java_google_java_format_options')
    let l:executable = ale#Var(a:buffer, 'java_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