eraserhd / parinfer-rust

A Rust port of parinfer.
ISC License
546 stars 42 forks source link

Provide a function to indent code? #59

Closed andreyorst closed 5 years ago

andreyorst commented 5 years ago

It would be nice to handle indentation with parinfer. Since it knows what correct indentation should line have in paren mode, would it be possible to make a function that indents current line? Kakoune has problems with default indentation in some lexical forms, and set's incorrect or unexpected amount of whitespace. It would be nice to fix it without going to paren mode.

eraserhd commented 5 years ago

Parinfer has some ability to indent a line, but only when the user is inserting a newline. Also, it is unaware of a lot of conventions and only worries about its invariant. For example, it doesn't know the body of a let or define should be indented two spaces, since one is sufficient to preserve the indentation/parenthesis invariant.

If there's some situation where Kakoune fails to indent, though, let me know. I made the current indent stuff, and want to keep it up-to-date. Actually, I can't remember if I made the Scheme stuff work, or just the Clojure. Maybe that needs to be copied, tested, and adjusted?

andreyorst commented 5 years ago

Understood. I now see that paren mode automatically sets only 1 space between parens not depending on the form syntax.