44" Use of this source code is governed by a BSD-style
55" license that can be found in the LICENSE file.
66
7- function ! zig#fmt#Format (do_astcheck ) abort
7+ function ! zig#fmt#Format () abort
88 " Save cursor position and many other things.
99 let view = winsaveview ()
1010
@@ -13,10 +13,7 @@ function! zig#fmt#Format(do_astcheck) abort
1313 return
1414 endif
1515
16- let cmdline = ' zig fmt --stdin'
17- if a: do_astcheck
18- let cmdline .= ' --ast-check'
19- endif
16+ let cmdline = ' zig fmt --stdin --ast-check'
2017 let current_buf = bufnr (' ' )
2118
2219 " The formatted code is output on stdout, the errors go on stderr.
@@ -80,38 +77,6 @@ function! zig#fmt#Format(do_astcheck) abort
8077 syntax sync fromstart
8178endfunction
8279
83- function ! zig#fmt#Astcheck () abort
84- if ! executable (' zig' )
85- echohl Error | echomsg " no zig binary found in PATH" | echohl None
86- return
87- endif
88-
89- let cmdline = ' zig ast-check'
90- let current_buf = bufnr (' ' )
91- if exists (' *systemlist' )
92- silent let out = systemlist (cmdline, current_buf)
93- else
94- silent let out = split (system (cmdline, current_buf))
95- endif
96- let err = v: shell_error
97-
98- if err == 0
99- call setloclist (0 , [], ' r' )
100- lclose
101- else
102- let errors = s: parse_errors (expand (' %' ), out)
103-
104- call setloclist (0 , [], ' r' , {
105- \ ' title' : ' Errors' ,
106- \ ' items' : errors,
107- \ })
108-
109- let max_win_height = get (g: , ' zig_fmt_max_window_height' , 5 )
110- let win_height = min ([max_win_height, len (errors)])
111- execute ' silent! lwindow ' . win_height
112- endif
113- endfunction
114-
11580" parse_errors parses the given errors and returns a list of parsed errors
11681function ! s: parse_errors (filename, lines ) abort
11782 " list of errors to be put into location list
0 commit comments