zls icon indicating copy to clipboard operation
zls copied to clipboard

Auto-insert semicolon after new line (not on save)

Open mnbnkr opened this issue 7 months ago • 1 comments

Related to #1476 (that has been reverted, so no semicolon insertion exists currently).

Maybe overall a better solution to inserting a semicolon if getting "expected ';' " error(s) - is to insert it when creating new line from the line where the error happens (with some other condition(s), like line having to end on " } ", etc).

It kind of makes more sense than doing this on save, and also makes this more flexible. Also add this as a setting in Config.zig.

Just overall want to bump this issue, even if solved in some other way, because it's such a prevalent thing, and seems like should be easy to solve.

mnbnkr avatar May 30 '25 12:05 mnbnkr

To be more precise, a very comprehensive semicolon insertion fix is not required - just a partial "smart newline" addition to current already existing would be enough. It's of course very useful only when you're inside some braces (the ending brace auto-created already) and don't want to manually go to end of line and insert semicolon and only then go new line - you should just go new line (from inside some braces, or when declaration/statement is ending on some brace) and have semicolon inserted automatically.

mnbnkr avatar Jun 01 '25 11:06 mnbnkr