@@ -75,3 +75,45 @@ Errors are reported using the quickfix list.
7575 :echomsg string(map(getqflist(),
7676 |'v:val.lnum . "," . v:val.col . "," . v:val.text'))
7777 ~ ['2,15,syntax error near ]']
78+
79+ Note that if the file's path was passed to buildifier, error reports are in a
80+ slightly different format, prefixed with the filename we passed.
81+
82+ @clear
83+ :silent file /foo/bar/BUILD
84+ :set filetype=bzl
85+ % load()
86+
87+ > go
88+ :FormatCode
89+ ! buildifier .*2> (.*)
90+ $ echo '/foo/bar/BUILD:1:7: syntax error near )' >\1 (command)
91+ $ 1 (status)
92+ load()
93+ @end
94+
95+ We'll be on column 6 because there's no column 7. (Buildifier appears to always
96+ report one column past the actual error.)
97+
98+ :echomsg line('.') . ',' . col('.')
99+ ~ 1,6
100+ :echomsg string(map(getqflist(),
101+ |'v:val.lnum . "," . v:val.col . "," . v:val.text'))
102+ ~ ['1,7,syntax error near )']
103+
104+ If there are no errors, then the quickfix list is (currently, see
105+ https://github.com/google/vim-codefmt/issues/58) left alone:
106+
107+ > godd
108+ % load('@io_bazel_rules_go//proto:def.bzl','go_proto_library')
109+ > go
110+
111+ :FormatCode
112+ ! buildifier -path /foo/bar/BUILD .*
113+ $ load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
114+
115+ :echomsg line('.') . ',' . col('.')
116+ ~ 1,1
117+ :echomsg len(getqflist())
118+ ~ 1
119+ :set filetype=
0 commit comments