The primary use of gq or formatprg is to format a visual selected block or text-motion selected block. zig fmt --stdin requires the entire context of either the container you are writing or the file to be able to format reasonably. For example, one of my primary uses for gq is to wrap the text at some width, especially documentation comments. For example:
const Stage = struct {
/// All the world’s a stage, And all the men and women merely players; They have their exits and their entrances; And one man in his time plays many parts, His acts being seven ages. At first the infant, Mewling and puking in the nurse’s arms;
players: []const u32,
};
Now, zig fmt doesn't format the documentation comment to a fixed column size on save. But if I try to select the line I want wrapped and run gq, I get:
The primary use of
gq
orformatprg
is to format a visual selected block or text-motion selected block.zig fmt --stdin
requires the entire context of either the container you are writing or the file to be able to format reasonably. For example, one of my primary uses forgq
is to wrap the text at some width, especially documentation comments. For example:Now,
zig fmt
doesn't format the documentation comment to a fixed column size on save. But if I try to select the line I want wrapped and rungq
, I get:On the other hand, if I select the entire context (struct definition), I run into the same issue that
zig fmt
doesn't care about column length.I would suggest we remove
formatprg
altogether as I believe that anyone using this plugin is probably usingzig fmt
on save anyway.