Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions autoload/codefmt/buildifier.vim
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ function! codefmt#buildifier#GetFormatter() abort
" @flag(buildifier)
" @throws ShellError
function l:formatter.Format() abort
let l:lint_flag = s:plugin.Flag('buildifier_lint_mode')
let l:cmd = [ s:plugin.Flag('buildifier_executable') ]
if l:lint_flag != ""
let l:cmd += ["--lint=" . l:lint_flag]
endif
let l:fname = expand('%:p')
if !empty(l:fname)
let l:cmd += ['-path', l:fname]
Expand Down
8 changes: 8 additions & 0 deletions doc/codefmt.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ Default: 'gn' `
The path to the buildifier executable.
Default: 'buildifier' `

*codefmt:buildifier_lint_mode*
Buildifier --lint=lint_mode parameter. Set to 'fix' to autofix issues.
Default: '' to not pass the flag and use the buildifier default (off)
Off: Do not fix issues.
Fix: Fix issues automatically during formatting.
Warn: Format only if there are no issues; if there are issues
it will cause an error and do no formatting.

*codefmt:google_java_executable*
The path to the google-java executable. Generally, this should have the form:
`java -jar /path/to/google-java`
Expand Down
8 changes: 8 additions & 0 deletions instant/flags.vim
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ call s:plugin.Flag('gn_executable', 'gn')
" The path to the buildifier executable.
call s:plugin.Flag('buildifier_executable', 'buildifier')

""
" The lint_mode for buildifier, defaults to not passing the flag.
" set to 'fix' to fix issues automatically during formatting,
" or 'off' to explicitly not fix issues (the current buildifier default).
" Setting to 'warn' will format only if there are no issues; if there are
" issues it will cause an error and do no formatting.
call s:plugin.Flag('buildifier_lint_mode', '')

""
" The path to the google-java executable. Generally, this should have the
" form:
Expand Down