Fork me on GitHub

Then it gets a “file was updated on disk” event, which I can catch but I can’t modify the document during.


Then after that I get some document updates, which I debounce and run parinfer after 10ms.


Unfortunately there’s no way I can think of to reliably run paren mode between the updates, since I don’t have the intermediate document states when I finally come to run indent mode after debouncing.


i.e. if there’s a file reload event I can mark that file as needing paren mode, but if there are more updates before I actually run paren mode then the document is modified in place and I can’t get the previous version. Even if I could, if paren mode modifies it then the later updates may be invalid since the document will have changed.


Ugh I'm glad I didn't go far down the road of trying to write a neovim backed intellij editor plugin.


@snoe: Yeah, I’ve actually considered that myself but I suspect it would be difficult.


All the complexity means that massive codebases work really well, but this sort of integration is not easy. This is one of the most difficult things I’ve had to shoehorn into IntelliJ, which I didn’t expect.


what a nightmare


I’m not sure there is a precedent for the type of transformation that parinfer performs


and I think that is why editor integration has been difficult


editors do not anticipate plugins to act as a kind of middleware like this


@shaunlebron: I’d agree with that - I can’t think of any other transformation that works like this, except something like file formatting.


And that’s generally integrated pretty deeply into the editor.


Certainly IntelliJ isn’t really designed for it, but it’s not really designed for text-based manipulation based on events in general.


Anyway, my workaround now works, the only corner case is if the user manages to create a manual event within 10ms of the file being opened, that event will get paren mode instead of indent mode. It seems very unlikely that this could happen based on user input, but some kind of plugin modifying the doc based on some event might happen.


@cfleming: thank you for staying on top of parinfer-jvm and pushing that update with previewCursorScope


@jasongilman: not yet; still need to give it a think. have been focusing elsewhere the last week or so


@chrisoakman: No worries, I’ll have to push a point release, I realised that there are some === that sneaked in there from cut’n’pasted code.


All the tests pass, it may not actually be a problem, but I’ll fix that in the next couple of days.


It’s pretty impressive that copying JS actually produces almost valid Kotlin.


That's mildly hilarious.


Thanks @chrisoakman. Parinfer in Atom is great. I never hear anyone mention Atom and Clojure without also saying "And of course you should use Parinfer too"


i released nightcode 1.1.0 with parinfer 😃 i’ll be teaching my java class some clojure next week using it so i’ll let y'all know how it goes


@sekao: Awesome, I’d love to hear if it’s helpful for them.