-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calculate indentation when user presses Enter #14
Comments
Indentation-on-enter indeed doesn't seem to be working correctly, at least on my setup, which makes writing even simple code with Parinfer active awfully difficult. For instance: ; | is my cursor
(defun id (x)|)
; enter
(defun id (x))
|
; manual indentation now required to start the function body! The correct indentation does appear to be applied in this case, where the indent merely must match the previous line exactly: (define blahs '(a
b
c|))
; enter
(define blahs '(a
b
c))
|
; cursor's in perfect spot to add extra item to the list, directly under c But the very common case where the current form must be continued, by increasing indent on Enter, is not successfully supported. Note that the official Parinfer demos produce correct indentation in both of these examples. I've tested under both language-lisp and language-racket, with exactly the same results - I'm not sure whether the active filetype actually affects Atom's indentation logic anyway, but it didn't help here. |
Yeah, this is really disappointing trying to use it with Clojure. Has anybody come up with a fix (to what I assume is a problem with Atom's Clojure indentation logic)? |
I have been annoyed with this recently too. |
Does that imply that it wasn't always this way? |
I'm not sure. |
Another indent mode example for the record (def m {:a 1|})
(def m {:a 1})
| Six spaces off from where you need it to continue the map. |
Thanks for the examples @00Davo and @neverfox The crux of the problem is that Atom does not indent based on language grammars. The python community has been most vocal about this, and they recently created a stopgap package for it. We could follow by taking cues from indentation rules documented for emacs or vim, or do a quick, partial solution using parinfer itself. |
I go this working when pressing enter inside a Paren Trail, but I have to think more about how to do this when pressing enter further inside a line. Tracking at https://github.com/shaunlebron/parinfer/issues/97 |
In the new Atom guide on the ClojureScript site, I pointed people towards the solution on Jason Gilman's opinionated setup page, which is to install the Paredit plugin and only assign the keybinding for the "Enter" key. If anyone finds a better solution or if Parinfer ends up at a place where it can do this on it's own, please send a PR to the ClojureScript site! |
This is actually fixed in latest Parinfer: dependent on #78 being merged |
@shaunlebron After playing with it, Parinfer's auto-indentation feels a bit weird. But I can continue that discussion in https://github.com/shaunlebron/parinfer/issues/59 rather than here. |
We should probably calculate where to put the cursor when the user presses
Enter
. The cursor should be right at the current indentation threshold.I'm not sure if Atom is doing this correctly by itself.
The text was updated successfully, but these errors were encountered: