File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ function! zig#fmt#Format() abort
13
13
return
14
14
endif
15
15
16
- let cmdline = ' zig fmt --stdin'
16
+ let cmdline = ' zig fmt --stdin --ast-check '
17
17
let current_buf = bufnr (' ' )
18
18
19
19
" The formatted code is output on stdout, the errors go on stderr.
@@ -22,8 +22,19 @@ function! zig#fmt#Format() abort
22
22
else
23
23
silent let out = split (system (cmdline, current_buf))
24
24
endif
25
+ if len (out) == 1
26
+ if out[0 ] == " error: unrecognized parameter: '--ast-check'"
27
+ let cmdline = ' zig fmt --stdin'
28
+ if exists (' *systemlist' )
29
+ silent let out = systemlist (cmdline, current_buf)
30
+ else
31
+ silent let out = split (system (cmdline, current_buf))
32
+ endif
33
+ endif
34
+ endif
25
35
let err = v: shell_error
26
36
37
+
27
38
if err == 0
28
39
" remove undo point caused via BufWritePre.
29
40
try | silent undojoin | catch | endtry
You can’t perform that action at this time.
0 commit comments