diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2021-06-27 10:07:29 +0200 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2021-06-27 10:07:29 +0200 |
commit | 4f5388350be1052f610b830c8fce8fbc17370ec6 (patch) | |
tree | 425cb8ee70c123233055a61d56d73e2eb97536db /autoload/zig/fmt.vim | |
parent | 4899585281beab51e5dff1d9ae4d3159244a8275 (diff) | |
download | vim-polyglot-4f5388350be1052f610b830c8fce8fbc17370ec6.tar.gz vim-polyglot-4f5388350be1052f610b830c8fce8fbc17370ec6.zip |
Update
Diffstat (limited to 'autoload/zig/fmt.vim')
-rw-r--r-- | autoload/zig/fmt.vim | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/autoload/zig/fmt.vim b/autoload/zig/fmt.vim index 7d7872f9..e2e3059a 100644 --- a/autoload/zig/fmt.vim +++ b/autoload/zig/fmt.vim @@ -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 |