tlaplus / vscode-tlaplus

TLA+ language support for Visual Studio Code
MIT License
340 stars 29 forks source link

This is awesome #67

Closed hwayne closed 4 years ago

hwayne commented 4 years ago

No real issue, just wanted to say how much I appreciate you making this :D

hwayne commented 4 years ago

Not sure how easy this is in VSCode, but one of the things I've configured in my vim extension is coloring in all primed operators. So if you have

/\ foo < bar
/\ foo' \in bar..10

It would also color the foo'. Makes it easier to skim raw TLA+ specs! I'd recommend trying it out if you write a lot of those :)

alygin commented 4 years ago

Thank you so much for the feedback, I really appreciate it! And thanks for the advise on highlighting primed operators. It really makes sense, and should be pretty easy to implement.

alygin commented 4 years ago

It would also color the foo'. Makes it easier to skim raw TLA+ specs!

@hwayne , implemented in v0.7.0 along with many other syntax highlighting improvements.

BTW, any thoughts on proper indentation of TLA+/PlusCal code?

hwayne commented 4 years ago

I don't think there's enough users to have "proper" indentation, but my preference is two spaces. This is because I tend to use a lot of levels. Taking the sample someone provided in favor of four:

ReplaceNode(table, id, new) ==
    LET bs  == table.buckets
        k   == CHOOSE k \in 0..Len(bs): id \in {n.id : n \in bs[k]}
        old == CHOOSE old \in bs[k]: old.id = id
    IN
        [table EXCEPT !.buckets[k] = (bs[k] \ {old}) \cup {new}]

I might rewrite it as

ReplaceNode(table, id, new) ==
  LET 
    bs  == table.buckets
    k == 
      CHOOSE k \in 0..Len(bs):
        id \in {n.id : n \in bs[k]}
    old == 
      CHOOSE old \in bs[k]: 
        old.id = id
  IN
    [table EXCEPT 
      !.buckets[k] = (bs[k] \ {old}) \cup {new}
    ]

That's an extreme example, but it helps when working with /\ and \/ chains.