@@ -150,7 +150,7 @@ local function do_fmt(buf)
150150 if config .fn then
151151 return config .fn (buf , range , acc )
152152 else
153- local result = spawn .transform (util .get_cmd (config , fname , buf ), cwd , config , acc )
153+ local result = spawn .transform (util .get_cmd (config , fname ), cwd , config , acc )
154154 if type (result ) == ' table' then
155155 -- indicates error
156156 errno = result
@@ -193,36 +193,36 @@ local function do_fmt(buf)
193193 -- wait until substitution is finished
194194 coroutine.yield ()
195195
196- impure :each (function (config )
197- if errno then
198- return
199- end
200-
201- vim .system (util .get_cmd (config , fname , buf ), {
202- text = true ,
203- cwd = cwd ,
204- env = config .env or {},
205- }, function (result )
206- if result .code ~= 0 and # result .stderr > 0 then
207- errno = result
208- --- @diagnostic disable-next-line : inject-field
209- errno .cmd = config .cmd
210- coroutine.resume (co )
211- else
212- coroutine.resume (co )
196+ if impure and # impure :totable () > 0 then
197+ impure :each (function (config )
198+ if errno then
199+ return
213200 end
214- end )
215201
216- coroutine.yield ()
217- end )
202+ vim .system (util .get_cmd (config , fname ), {
203+ text = true ,
204+ cwd = cwd ,
205+ env = config .env or {},
206+ }, function (result )
207+ if result .code ~= 0 and # result .stderr > 0 then
208+ errno = result
209+ --- @diagnostic disable-next-line : inject-field
210+ errno .cmd = config .cmd
211+ coroutine.resume (co )
212+ else
213+ coroutine.resume (co )
214+ end
215+ end )
218216
219- if errno then
220- fail ((' %s exited with code %d\n %s' ):format (errno .cmd , errno .code , errno .stderr ))
221- return
222- end
217+ coroutine.yield ()
218+ end )
223219
224- -- refresh buffer
225- if impure and # impure :totable () > 0 then
220+ if errno then
221+ fail ((' %s exited with code %d\n %s' ):format (errno .cmd , errno .code , errno .stderr ))
222+ return
223+ end
224+
225+ -- refresh buffer
226226 vim .schedule (function ()
227227 api .nvim_buf_call (buf , function ()
228228 local views = save_views (buf )
0 commit comments