File tree 2 files changed +14
-5
lines changed
2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,12 @@ function! codefmt#buildifier#GetFormatter() abort
39
39
" @flag(buildifier)
40
40
" @throws ShellError
41
41
function l: formatter .Format () abort
42
- let l: cmd = s: plugin .Flag (' buildifier_executable' )
42
+ let l: cmd = [ s: plugin .Flag (' buildifier_executable' ) ]
43
+ let l: fname = expand (' %:p' )
44
+ if ! empty (l: fname )
45
+ let l: cmd += [' -path' , l: fname ]
46
+ endif
47
+
43
48
let l: input = join (getline (1 , line (' $' )), " \n " )
44
49
try
45
50
let l: result = maktaba#syscall#Create (l: cmd ).WithStdin (l: input ).Call ()
Original file line number Diff line number Diff line change 1
- The built-in buildifier formatter knows how to format Bazel BUILD files. If you
2
- aren't familiar with basic codefmt usage yet, see main.vroom first.
1
+ The built-in buildifier formatter knows how to format Bazel BUILD and .bzl
2
+ files. If you aren't familiar with basic codefmt usage yet, see main.vroom
3
+ first.
3
4
4
5
We'll set up codefmt and configure the vroom environment, then jump into some
5
6
examples.
@@ -38,14 +39,17 @@ buildifier_executable flag if the default of "buildifier" doesn't work.
38
39
$ )
39
40
:Glaive codefmt buildifier_executable='buildifier'
40
41
41
- The bzl filetype will use the buildifier formatter by default.
42
+ The bzl filetype will use the buildifier formatter by default. The path to the
43
+ file being edited is passed to buildifier so that it can adjust to whether the
44
+ file is a BUILD or .bzl file.
42
45
43
46
@clear
44
47
% foo_library(name = "foo", srcs = ["bar.js"],)
45
48
49
+ :silent file /foo/bar/BUILD
46
50
:set filetype=bzl
47
51
:FormatCode
48
- ! buildifier .*
52
+ ! buildifier -path /foo/bar/BUILD .*
49
53
$ foo_library(
50
54
$ name = "foo",
51
55
$ srcs = ["bar.js"],
You can’t perform that action at this time.
0 commit comments