File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,11 @@ function! codefmt#buildifier#GetFormatter() abort
3939 " @flag(buildifier)
4040 " @throws ShellError
4141 function l: formatter .Format () abort
42+ let l: lint_flag = s: plugin .Flag (' buildifier_lint_mode' )
4243 let l: cmd = [ s: plugin .Flag (' buildifier_executable' ) ]
44+ if l: lint_flag != " "
45+ let l: cmd += [" --lint=" . l: lint_flag ]
46+ endif
4347 let l: fname = expand (' %:p' )
4448 if ! empty (l: fname )
4549 let l: cmd += [' -path' , l: fname ]
Original file line number Diff line number Diff line change @@ -105,6 +105,14 @@ Default: 'gn' `
105105The path to the buildifier executable.
106106Default: 'buildifier' `
107107
108+ *codefmt:buildifier_lint_mode*
109+ Buildifier --lint=lint_mode parameter. Set to 'fix' to autofix issues.
110+ Default: '' to not pass the flag and use the buildifier default (off)
111+ Off: Do not fix issues.
112+ Fix: Fix issues automatically during formatting.
113+ Warn: Format only if there are no issues; if there are issues
114+ it will cause an error and do no formatting.
115+
108116 *codefmt:google_java_executable*
109117The path to the google-java executable. Generally, this should have the form:
110118`java -jar /path/to/google-java`
Original file line number Diff line number Diff line change @@ -100,6 +100,14 @@ call s:plugin.Flag('gn_executable', 'gn')
100100" The path to the buildifier executable.
101101call s: plugin .Flag (' buildifier_executable' , ' buildifier' )
102102
103+ " "
104+ " The lint_mode for buildifier, defaults to not passing the flag.
105+ " set to 'fix' to fix issues automatically during formatting,
106+ " or 'off' to explicitly not fix issues (the current buildifier default).
107+ " Setting to 'warn' will format only if there are no issues; if there are
108+ " issues it will cause an error and do no formatting.
109+ call s: plugin .Flag (' buildifier_lint_mode' , ' ' )
110+
103111" "
104112" The path to the google-java executable. Generally, this should have the
105113" form:
You can’t perform that action at this time.
0 commit comments