Skip to content

Consider supported wrapping at relative column. #49

@matklad

Description

@matklad

My code has 100 columns as a hard limit. This balances the desire to allow nested indentation, while still allowing comfortable side-by-side view. However, 100 characters is too wide for prose, like comments. When I write the comment, I want to wrap the comment text itself at 60, regardless of leading indentation, unless, of course, the indentation pushes me over the total limit.

Here's an example to make this clear:

// For this top-level function, I want the comments to be
// wrapped at human-readable-length (about 60 characters).
fn GenericType(comptime T: type) type {
    return struct {
        const Nested = struct {
            // For nested code, I still want comments to be wrapped at 60,
            // _relatively_. That is, indentation and leading comment
            // markers themselves are excluded from the limit computation,
            // so the block "sticks out" relative to the top-level block.
            const Deeply = enum {
                fn fun() void {
                    while (true) {
                        switch (foo) {
                            else => {
                                switch (bar) {
                                    else => {
                                        for (ever) |young| {
                                            if (@"to be or not to be") {
                                                // However, if I am so deranged as to have enough
                                                // levels of indentation to eat more than half of
                                                // the overall 100 character hard limit, its only
                                                // proper if I am punished with having to cram my
                                                // graphomany into a much narrower field!
                                            }
                                        }
                                    },
                                }
                            },
                        }
                    }
                }
            };
        };
    };
}

There is "rewrap.wrappingColumn": 60, but it controls the absolute wrapping for comments, not the relative one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions