export def Do()
var view = winsaveview()
- normal gg=G
+ silent execute ":%!" .. &equalprg
+ if v:shell_error != 0
+ var errs = []
+ for line in getline(1, line("$"))
+ var cols = matchlist(line, '^.*:\(\d\+\):\(\d\+\):\s*\(.*\)$')
+ if empty(cols) | continue | endif
+ errs = add(errs, {
+ filename: @%,
+ lnum: str2nr(cols[1]),
+ col: str2nr(cols[2]),
+ text: cols[3],
+ })
+ endfor
+ silent undo
+ if !empty(errs) | setqflist(errs, "r") | endif
+ echohl Error | echomsg "fmt error" | echohl None
+ endif
winrestview(view)
enddef