Open lspector opened 2 years ago
I thought I'd add that this is pretty close to being a "must have" feature for me for teaching. "Do an auto-reformat and you'll see what's wrong" and "Do an auto-reformat and you'll see how you need to complete that expression" are probably among the things I say most to students learning Clojure. I've been teaching with Cursive lately and am considering Calva, and I think this is the primary thing that would block that move.
CC @PEZ
Thanks! Not sure why it wouldn't be useful in strict mode, even if you don't end up needing it as often.
It is probably worth noting that almost all of Calva stops working with unbalanced code. Including the tools we have for indenting and formatting.
I see that autocompletion does already work on unbalanced code, which is great. I'm not sure what else in Calva doesn't work with unbalanced code, aside from indenting, but there's probably a lot that one wouldn't even want to try to do until the expression that's being edited is completed and balanced. One of the key things for completing and balancing it, though, when in "cave man" (aka normal text editing :) mode, is indenting. Bracket matching and autocompletion are a couple of others.
There's probably no perfect way to do this, but many Clojure/lisp environments (e.g. Cursive, Counterclockwise, some Emacs setups, etc.) do a decent job, seemingly by going top to bottom and re-formatting on the assumption that anything opened will be properly closed at some point.
If the expression is correct except for being incomplete, then this will format what is there exactly correctly. If there are more severe structural problems, then although things will get wonky at some point, reading from top to bottom you can see the where it goes wonky and investigate.
I guess this is only relevant for people who don't work in a strict structural mode, but that includes me and all of my students (for considered reasons, and strict structural mode is not an option).