Comment

Comment by Pxtl

Honestly that's the indentation format I use for every language. Doing it in Lisp just makes sense.

My "OTBS all the things" rules:

- Never horizontal align. Indentation is a simple tree, with each set of children indented 1 layer deeper, which can be 4 spaces or 1 tab.

    ThisKindOfThing(
                    foo,
                    bar,
                    baz);
is generally dumb.

- If a block is worth indenting for, the end of the block deserves its own line. Just do OTBS but also for parentheses if you've a long function call.

  ThisKindOfThing (
      foo,
      bar,
      baz
  );
Is just more consistent and easier to manage while still being legible.

- if you're ever splitting something across multiple lines there must be an indent.

  myObj
      .Foo()
      .Bar()
      .Baz();
- you're allowed to double-dip on tree depth - that is indent only one level for like 3 levels of tree, as long as the opening of that 3-deep jump is a clear one-liner and the end of it is a line that says ")))".

  Foo(Bar(Baz(
      someVal
  )));
- when splitting lines on infix operators, anything but commas go at the start of the line (also, bedmas counts as tree depth)

  foo
      + bar
      + baz
      + (
          var1
          * var2
          * var3
      )
      + quux;
parent Pxtl 1 year ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton