This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-12-21
Channels
- # adventofcode (24)
- # announcements (1)
- # beginners (122)
- # braveandtrue (9)
- # calva (45)
- # cider (24)
- # cljdoc (8)
- # cljs-dev (23)
- # clojure (112)
- # clojure-europe (2)
- # clojure-india (2)
- # clojure-italy (36)
- # clojure-nl (3)
- # clojure-spec (32)
- # clojure-uk (35)
- # clojurescript (52)
- # core-typed (12)
- # cursive (4)
- # datomic (61)
- # emacs (4)
- # figwheel-main (2)
- # fulcro (14)
- # hoplon (5)
- # hyperfiddle (1)
- # jobs-discuss (6)
- # kaocha (5)
- # leiningen (2)
- # nrepl (15)
- # off-topic (62)
- # re-frame (26)
- # reagent (39)
- # ring (3)
- # shadow-cljs (56)
- # spacemacs (8)
- # specter (5)
- # tools-deps (1)
- # yada (2)
Good news. I got help from a real programmer to climb up out of the hole I had dug myself down in when it comes to the nrepl socket connection. So now the nrepl client code looks like so: https://github.com/BetterThanTomorrow/calva-lib/blob/talky-socket/src/calva/repl/client.cljs I have kept the API towards the Calva extension and only removed all the opening and closing of the sockets that previously embedded every message sent. That's in this branch: https://github.com/BetterThanTomorrow/calva/tree/keep-socket-open
There are still two issues, one which makes me hesitate to merge this into the main branches.
(Two issues that I am aware of and that bothers me enough to mention them, that is. I am sure there are still tons of issues hiding in there. đ )
For all the bugs and issues that were there with the previous implementation it is surprising how solid the nrepl messaging was. But there is a change that the issue with people's terminals hanging could have been one of them. I certainly hope so, but I know it could be a vain hope.
Anyway, the âsort of stopperâ is that I can see that I sometimes build up cruft in the atom keeping track of which response goes with witch request. This is not enough to tidy out all that needs to be tidied out: https://github.com/BetterThanTomorrow/calva-lib/blob/talky-socket/src/calva/repl/client.cljs#L61
I need to learn a bit more about nrepl to know what to do with :status ["state"]
messages for one. Calva has never used them, so just disregarding them might be the way to go.
the answer may lie in https://github.com/clojure-emacs/cider/blob/master/cider-connection.el
I guess to get this thing out of the door, avoiding that perfect gets in the way for better, is to keep track of which messages we consider handled and never accumulate them again in the *results
atom. Then have it on the TODO to handle things properly.
The other, less pressing, issue is that I currently have kept the super-naive bencode decoding strategy. Which might have bugs in it, even. A moment after the connection is established I get quite a lot of decoding errors. nrepl seems to send a LOT of things to me, none of which I see the relevance in (probably because of my lack of understanding, but anyway).
Shipping this new socket handling would in this respect keep this bencoding decode quality at the same low level. đ
yeah, I think the next big thing on the list after I get this formatter sane is to look at exactly how nrepl is used by cider
Re: bencode, I think the time is better spent shifting to use EDN transport. Or at least add that too the ways Calva can communicate.
hmm, am I calling this correctly? (reformat-string "(foo\nz\na\nb\nc)" {:alias-map '{foo [[:inner 2]]}})
so, on return I now walk up the tree, working out what argument position we're at, the head of the current list, and collect the indent rules along the backbone of the whole expression tree
but this is carefully limited so we don't tank performance with large files- so you can configure it to only look up so many lines, and only up so much depth, and it will fall back to heuristic indentation in that case
also currently this is purely for indentation only, although I can obviously correct whitespace issues too later.
To me it makes sense to do the indenting with your stuff there and do formatting with cljfmt and zprint. What do you think about that?
Yeah, I think so. emacs' reformat commands are more precise than the much simpler format on type stuff
in fact, though emac's formatting rules are far simpler anyway- they don't nest deeply like cljfmts, so they have it even easier đ
Although currently you can see the function collectIndentState
, which is working correctly to retrieve all the information required to compute the next indent.
https://github.com/mseddon/calva-fmt/blob/restartable-formatter/calva-fmt/docmirror/index.ts#L589 with the emacs-based navigation commands it's actually pretty trivial.
Okay! Have at it! the restartable-formatter
branch has a prototype working implementation!
it'll do stupid stuff if its search bails at this point probably, but in general it should indent the same as cljfmt so long as its search covers enough!
so yeah, need some simple 'indent to same as last sibling expression' sort of heuristic for when that happens.
I will probably also treat any parent list on column 0 as the start, to prevent scouring too far above. I assume your code is mostly correctly formatted... otherwise you should use the proper reformatting tools
incremental calva-fmt indentation, in typescript, in 70 lines total (except for the rules of course).
Yay! Can't wait to test this. (But I'll have to. On my way to a glögg-party with my family.)