Skip to content

Commit de9c2c6

Browse files
mluggandrewrk
authored andcommitted
Add ZON support to zig fmt integration
Also, remove a legacy codepath which handled old Zig versions without support for `zig fmt --ast-check`.
1 parent 15d6510 commit de9c2c6

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

autoload/zig/fmt.vim

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ function! zig#fmt#Format() abort
1414
endif
1515

1616
let cmdline = 'zig fmt --stdin --ast-check'
17+
if expand('%:e') is? 'zon'
18+
let cmdline = cmdline . ' --zon'
19+
endif
20+
1721
let current_buf = bufnr('')
1822

1923
" The formatted code is output on stdout, the errors go on stderr.
@@ -22,19 +26,8 @@ function! zig#fmt#Format() abort
2226
else
2327
silent let out = split(system(cmdline, current_buf))
2428
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
3529
let err = v:shell_error
3630

37-
3831
if err == 0
3932
" remove undo point caused via BufWritePre.
4033
try | silent undojoin | catch | endtry

0 commit comments

Comments
 (0)