This commit is contained in:
Adam Stankiewicz
2021-06-27 10:07:29 +02:00
parent 4899585281
commit 4f5388350b
21 changed files with 77 additions and 43 deletions

View File

@@ -17,7 +17,7 @@ function! zig#fmt#Format() abort
return
endif
let cmdline = 'zig fmt --stdin'
let cmdline = 'zig fmt --stdin --ast-check'
let current_buf = bufnr('')
" The formatted code is output on stdout, the errors go on stderr.
@@ -26,8 +26,19 @@ function! zig#fmt#Format() abort
else
silent let out = split(system(cmdline, current_buf))
endif
if len(out) == 1
if out[0] == "error: unrecognized parameter: '--ast-check'"
let cmdline = 'zig fmt --stdin'
if exists('*systemlist')
silent let out = systemlist(cmdline, current_buf)
else
silent let out = split(system(cmdline, current_buf))
endif
endif
endif
let err = v:shell_error
if err == 0
" remove undo point caused via BufWritePre.
try | silent undojoin | catch | endtry