Closed hovsater closed 3 years ago
What's the output of :mess
after writing the file? Can you show the code you're trying to save?
Consider a file named example.zig
with the following contents:
const std = @import("std");
pub fn main() !void {
try std.io.getStdOut().writer().print("hello, world!\n", .{})
}
saving it in Vim causes the location list to open but show no errors. The actual error from running zig run example.zig
is:
~/code/zig $ zig run example.zig
./example.zig:5:1: error: expected token ';', found '}'
}
^
The output of :mess
after saving the file is:
zig fmt returned error
"example.zig" 5L, 119B written
The output of :mess after saving the file is:
Is that all? There must be something else before that.
What's the output of :echo executable('zig')
?
@LemonBoy this is the entire :mess
buffer:
Messages maintainer: Bram Moolenaar <Bram@vim.org>
"example.zig" 5L, 119B
zig fmt returned error
"example.zig" 5L, 119B written
The output of :echo executable('zig')
is 1
. Formatting also works correctly upon save if the file doesn't contain any errors.
The plot thickens. Can you dump the list of errors here and the contents of stderr_file
? Somehow the data returned by zig fmt is being lost.
Sure thing.
Contents of the stderr_file
:
['<stdin>:5:1: error: expected '';'', found ''}''']
Contents of the errors
variable:
[{'lnum': '5', 'col': '1', 'filename': 'example.zig', 'text': ': error: expected '';'', found ''}'''}]
The parameters look correct :\ One more check, what's the output of :echo getloclist(0)
after the loclist opens?
Do you have some other plugin that may be interfering with this one?
Oh, I think I found the culprit. It's ALE!
I guess, setting g:zig_fmt_parse_errors
to 0
will solve the problem, since I do error handling with ALE. 🙂
Thanks for taking the time to debug this with me. Really appreciate it.
You've beat me to the punch, setting zig_fmt_parse_errors
does indeed stop the plugin from parsing the error messages.
Thanks for taking the time to debug this with me. Really appreciate it.
Np, thanks for using zig (and zig.vim) :)
Whenever I save a Zig file that's in a broken state, the location list opens but doesn't contain any errors. It's always empty.
This is on macOS, version
11.2.1
using the latest version of this plugin.