This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-12-13
Channels
- # adventofcode (84)
- # aleph (1)
- # announcements (2)
- # aws (27)
- # beginners (52)
- # braveandtrue (2)
- # calva (440)
- # cider (7)
- # clara (2)
- # cljdoc (26)
- # cljs-dev (70)
- # clojure (131)
- # clojure-berlin (4)
- # clojure-brasil (1)
- # clojure-europe (2)
- # clojure-greece (4)
- # clojure-hamburg (1)
- # clojure-italy (4)
- # clojure-losangeles (6)
- # clojure-nl (14)
- # clojure-spec (7)
- # clojure-uk (25)
- # clojurescript (26)
- # component (2)
- # cursive (13)
- # datomic (60)
- # dirac (59)
- # docker (1)
- # figwheel (1)
- # figwheel-main (2)
- # fulcro (12)
- # graphql (5)
- # juxt (33)
- # leiningen (19)
- # nrepl (1)
- # off-topic (37)
- # protorepl (2)
- # re-frame (18)
- # reagent (46)
- # remote-jobs (1)
- # ring-swagger (1)
- # shadow-cljs (88)
- # sql (10)
- # tools-deps (64)
- # vim (24)
Hi I just installed calva and corresponding paredit plugin. I ran lein repl
in an existing project (added cider-nrepl to project.clj). then opened the project folder in VSCode. I typed Alt V E
on (println "helloworld")
. It displayed the return value of nil
but not the string. The string was not visible in the terminal as well.
Not sure if I have everything configured correctly..
Looking for nREPL sessions...
Clojure 4 VS Code activated. Happy coding! ❤️
Please file any feature requests or bug reports here:
I will also respond to any @pez mentions in the #editors shannel of the Clojurians Slack:
Note: Autolinting is now diabled by default. You need to enable "clojure4vscode.lintOnSave" in your editor settings to use it. But first install Joker:
-------------------------
Connected session: clj
clj session used for cljc
Evaluating:
(println "hello world")
----------------------------
nil
@pez removing this line fixes the cond formatting https://github.com/weavejester/cljfmt/blob/master/cljfmt/src/cljfmt/core.cljc#L250
It seems wrong that the cond forms we are talking about should meet the criteria of codeless-block?
.
So, without having checked the code or anything my hunch is now that the bug lives where codeless-block?
is determined. (Also without nowing what a block is. )
if I understand correctly, codeless-block is weirdly just looking at the right of a zipper to see if it's nil...
so... I don't see how that relates to codeless blocks yet. I need to dig deeper into their representation
there's very little smarts about forms, basically it is this: https://github.com/weavejester/cljfmt/blob/master/cljfmt/resources/cljfmt/indents/clojure.clj
I think it should be handled like "how would it be indented if there was a symbol just before the end-of-block?"
If you wanna hear me scream of happiness you should fix this problem: https://github.com/weavejester/cljfmt/issues/154 😃
btw I came up with probably the cheesiest but might actually work solution for https://github.com/BetterThanTomorrow/calva-fmt/issues/6
basically splitting the string along "\r\n|\n", figuring out where the offsets are, and repositioning. each line has a start offset and in CRLF mode, the offset bumps 2 chars (for cr/lf), but only one in LF...
Not sure how updated it is with my experiments but there is a branch named crlf-dabblings
.
Hi, the Getting started document short cuts in github and what I see in VSCode are not matching . VS Code does not expect me to type the CTRL key
@manas.marthi That screenshot is from a really old version of Calva!
I just installed calva now
hmm may be my company vscode is old
and it is downloading an old version of calva
yeah, I am using 1.13.0
vscode website shows 1.30
They're in the middle of changing that (or if they have already) using Reeve's test framework, I think.
Hi @pez, is 1.3.58 the latest version of calva ?
Ran 11 tests containing 128 assertions.
0 failures, 0 errors.
Running ClojureScript test: dev
Testing cljfmt.core-test
Ran 11 tests containing 128 assertions.
0 failures, 0 errors.
Hi @pez do I need anyother plugins other than calva?
@manas.marthi, no, I think you should be good with Calva. It bundles Calva Paredit and Calva Formatter (which has some little Parinfer built in).
okay, tq.. I have difficulty getting the indentation working okay. Also, a lot of times, when I hit the enter key the cursor is coming back to the end of line
@manas.marthi Give me some examples and maybe I can see if it is by design or some bug.
hello 👋 I'm getting a FileNotFoundException Could not locate cljs_react_material_ui/reagent__init.class or cljs_react_material_ui/reagent.clj on classpath.
error in Calva's ClojureScript REPL and I'm a bit lost trying to fix it! Is this a Calva problem or a Leiningen problem? (sorry I'm a beginner but this slack doesn't let me search back very far! any help is super appreciated!)
I've been loosing all week, so I'm treating myself with little OSS bugfixes this afternoon 😉
@pez The editing seems to work fine if I am at the end of the buffer. However if I start typing in the middle of the file it does not work
Clojure
(defn give-me-a-map []
{:r 128
:g 128
:b 128
} )
try typing up to :r 128
in the middle of a file
and hit enter after 128
the cursor is returning to previous line
besides the indentation is not preserved when I edit in the middle of the file.
@manas.marthi oh, heads up, weird stuff happens if you are in CRLF mode atm, so ensure your file is LF only... 😕
@mseddon got it. I changed to LF. It seems to work fine
@manas.marthi ah, okay, yeah, it's a silly bug that's definitely on the list 🙂 I will try to get to it soon
I'm not sure where the problem is, @tomd, but I'm pretty sure it isn't Calva. I'd be happy to try help you get going anyway, of course.
OK. A problem with Calva sometimes is that it cuts a lot of some stack traces. Is it a figwheel project?
Run the cljsbuild plugin.wmato>
Subtasks available:
once Compile the ClojureScript project once.
auto Automatically recompile when files are modified.
test Run ClojureScript tests.
repl-listen Run a REPL that will listen for incoming connections.
repl-launch Run a REPL and launch a custom command to connect to it.
repl-rhino Run a Rhino-based REPL.
sample Display a sample project.clj.
Run `lein help cljsbuild $SUBTASK` for subtask details.
Arguments: ([once auto test repl-listen repl-launch repl-rhino sample])
I got one successful Compiling
and then the next one failed with a couple of long stack traces. It terminated with Subprocess failed
"resources/public/js/compiled/app.js"
was the one that compiled successfully and
"resources/test/js/testable.js"
was the one that failed 😞
Paste it as a snippet here. I might have to run soon and then maybe someone else can try help you.
Also #beginners is a very friendly channel. Just so that you know. I have seldom seen a community as friendly as the Clojure one.
awesome! I only asked here because I thought it may be a calva problem. thanks for helping anyway.
As a beginner it is often really hard to know where the errors come from. Clojure error messages are generally improving, but also generally a bit lacking.
nothing. calva automatically starts it when I open a cljs file and press ctrl-j to see the terminal
Sometimes, if you have a cljs-repl, you can get a stack trace with good info if you do (reset-autobuild) in that repl.
hi, how do I change calva to use ctrl+comma
instead of ctrl+alt+v
@manas.marthi that will be a bit of work. Search for ctrl+alt+v
in the keyboard shortcuts pane, and then edit all those commands...
Maybe you can pluck out the shortcuts from Calva's package.json and paste them in your user settings… Then do search and replace.
@pez I added { "key": "ctrl+, e", "command": "calva.evaluateSelection" },
it worked
Not sure if it conflicts with any other plugins
I see that ctrl+,
is quite free to use, @manas.marthi. It is probably a better default than ctrl+alt+v
. I'll have a think about it.
So far I have only clojure
This is what proto repl uses
As long as java, python, css, js, ts, xml, json plugins do not use it, we should be okay
[cljs-react-material-ui "0.2.44"]
is listed under :dependencies
in project.clj
so yes I think so @pez
@pez please review atom proto-repl short cuts
if we can keep things close to proto it can give easy switch over experience
(applicable to proto users)
the default emacs and spacemacs are a different bunch
Atom sucks behind proxy
vscode works for installing plugins
@manas.marthi, I hope to find a big chunk of time to add some ProtoREPL inspired stuff to Calva.
thank you. I see the slurp/barf stuff are under
commands
are there anything other commands that are not from calva.
Personally I use Emacs inspired keyboard shortcuts for the Paredit commands. Mainly because that is what I was used to.
Looks like the ritht way to use comma is "ctrl+oem_comma"
I see it is already assigned { "key": "ctrl+oem_comma", "command": "workbench.action.openSettings" },
I just searched in a new installation the slurp commands are with paredit
prefix
I will still override ctrl+oem_comma
. The number of times we open settings menu is far less than the number of times we evaluate forms
Another reason why VSCode appeals to me over atom: VSCode shows vertical guidelines to indicate the indentation and number of lines a s-exp extends to.
atom does not show that to me
I see the a bunch of errors in the Log (Extension Host)
not sure what they mean
@pez https://github.com/weavejester/cljfmt/commit/0ee55551f8e330d0df0df7a099cc2e603913b2ef
not my PR, but a more appropriate fix by weavejester addressing the issue is now merged into cljfmt
btw, where is this import coming from? https://github.com/BetterThanTomorrow/calva-fmt/blob/develop/calva-fmt/format.ts#L4
btw @pez just in case you are interested, I figured out I was trying to run clojurescript in the repl (which is pointing at the jvm, I guess)
Btw, i seldom use those terminal repls and rely much more on the inline repls in the text editors.
@pez is there a simple command I can run to test if it is actually connected to my figwheel?
:man-facepalming: sorry I'm such a n00b. I ran that and it says:
CompilerException java.lang.RuntimeException: No such namespace: js, compiling:(C:\Users\tomd\AppData\Local\Temp\form-init6609427845754296505.clj:1:1)
so does that mean there's a Calva problem? Calva thinks it connected to js but it connected to jvm?
@pez is it possible to make a separated extension that uses Calva core? or Paredit and fmt extensions don’t need it?
Because i think that a Calva: Re-frame Navigation extension would have a lot of features
When i get all the stuff i’m doing “on the road” i will start searching about making the re-frame extension
@pez see what happens with https://github.com/mseddon/calva-fmt/tree/crlf for you? it appears to function okay for me. There's really not much I changed to get it working so perhaps I am missing some erroneous behaviour.
I ran lein repl
in one powershell terminal and lein figwheel
in another (both terminals in vscode) and then did ctrl-alt-v c
and it autopopulated the port with the repl's port. calva then generated both repls, which i've learnt are both java repls (because (js/alert)
works in neither!!)
@mseddon you're probably not missing anything. I'll check later tonight when I'm at a computer.
@tomd, i see. That will not work, unfortunately. You'll need to start the figwheel repl from the first repl.
@mateus.pimentel.w it makes sense to do it as its own extension, yes. Let's have a chat about how we should best factor it.
i will be taking notes of the stuff i experience while making the tests with re-frame
@pez I caught you passing the entire contents of the buffer to clj-fmt. that gets EXTREMELY slow when you e.g. have a 9k line file. formatting takes several seconds 😉
but at least with 0.0.30-calva-lib, i see a massive slowdown before the formatting happens, related to the length of the file
currently there is a document.getText() call that shovels the whole thing over to cljfmt, too
i looked to see if we could enumerate the fold contexts and find that block.. but.. seems that it's opaque and we can't access them
Try expanding the selection in that file. (The calva command, not the vscode one, since i have not tied that one yet.
I don't think the whole text is sent to cljfmt, unless the whole file is to be formatted.
https://github.com/BetterThanTomorrow/calva-fmt/blob/develop/calva-fmt/format.ts#L24 i think it is happening here
If I can figure out how to profile the damn thing that'll help.. nothing's showing up in the profiler. 🙂
though one thing I wonder, but I don't know- you do an editor.edit() within the formatting functions, whereas the api suggests you return the edits from the callback
I would be quite surprised if the proper way doesn't allow for configuring the stops, though.
You could feed the whole file to the functions in calva-lib from the repl and see if they perform badly.
it's not a massive issue, although I really want to try and get the formatting 'instant' it's a bit disconcerting the way it pops into place moments later, even if there's just a 1 frame delay
okay so I think that fairly conclusively establishes that we didn't send the whole buffer to reformat-string 🙂
Also, I am really hoping that zprint will be moving in the direction where it can support Calva’s formatting better, so that we don’t have to do a lot of the stuff we are currently doing. Hence this: https://clojureverse.org/t/clj-commons-building-a-formatter-like-gofmt-for-clojure/3240/13?u=pez and this: https://clojureverse.org/t/i-need-some-zprint-config-examples/3121?u=pez (the whole thread).
zprint's maintainer is awesome, I would love for that to happen as well
I love that he wants to try help with this, and obviously is really thinking hard about it, even though he clearly thinks it might be too hard to fit it in to zprint’s model of things.
he has done an immense amount of work in tweaking that and make sure folks like it, based on analyzing actual code
he had a pretty nice talk at the Conj
sorry it was an unsession
so not recorded
yeah...
I think it is worth it..totally
yeah it does so many things
he showed that it actually ends at the margin you specify with some of the options, no char less, no char more
It’s funny. Because the reason I went with cljfmt was that I thought zprint was crazy with all those options. (Before I realized it couldn’t really be used for what I needed it to do.)
@mseddon your crlf branch is not too different from mine. Is that a coincidence or did you jump of from my experiments?
Really happy that you got it working! I am going to merge my calva-lib branch onto develop now, so I’d be really happy if you could reapply your fixes on the new develop as well as on the calva-lib repo as a PR when I am done. It changes the dev process a bit (not everything for the better).
I may also start a totally different formatter more akin to clojure-mode in emacs and see how well that works
Great. It’ll be a relief when I get this one merged. I can’t really handle too many branches. My brain starts to hurt.
Crap, I had a contract a while ago that had somethibg like 20 different repos and craploads of branches. It was no fun 😀
https://stackoverflow.com/questions/44206782/do-i-commit-the-package-lock-json-file-created-by-npm-5
Haha, Those seems like pretty good reasons, but why is the file changing all the time then?
To me it seems to be a moving piece, not a stabilizer at all. But, well, until I’ve read up more about it I’ll keep it checked in then.
It should only update when node modules is tweaked, but perhaps shadow-cljs is messing with installing or updating packages?
Hmm I had to npm i
when I checked out of course. It most likely got changed for me then. sigh.
@manas.marthi I saw those log errors you posted now. Missed it before. Don’t think I’ve seen it before, but will keep an eye open.
But anyway, if we get merge conficts in this file, let’s just solve them by picking --ours for everything.
I haven't looked into that.. could be done somehow probably, git has so many features...
It will be me publishing the npm module so maybe we can jsut .gitignore it and hope that it isn’t really needed for this project to be checked in.
Now I’ll need to updated the How to Contribute page. I wonder if anyone will still want to do that after reading it.
also i stuck a (time ,,,)
around the cljsfmt call on the clojure - we're looking at ~50ms with that giant file, and the latency seems to be coming before the call, so after a big profile party I may actually track down where that's going 🙂
thing is- if you start typing AFTER pressing return before vscode wakes up and applies the formatting, cljfmt is working with a stale copy of the document, and vscode ignores the update (literally, the newline indents at column 1 😞), so as files get bigger, on slow machines that is going to drive people nuts.
I think the next big priority is trying to get this happening instantly, and synchronously so it can't break/doesn't jump around on the screen.
I will open an issue to track this tomorrow once I have looked into it more, it seems we can do a pretty good job on this with cljfmt for now, it's our fault 😉. 50ms is on a really fast machine though, but it's all about the # cores these days so hopefully it's not too bad.
The synchronous thing might prove difficult. The #parinfer guys have tried hard with that extension and yet not succeeded.
I think the extension is single threaded so the number of cores doesn’t play in too much into the mix, I think. Fortunatelly I am a poor guy with a really slow machine so I can test things in such environments.
ah, goodie. 🙂 so long as you're not experiencing that silly race we may be fine once we've fixed this silliness
I can get it to behave a bit weird quite easily by entering new lines quickly in semi-large files.
It is binding a command to the ENTER key and make it do both the new line and format things in one set of edits.
For instance, enable strict mode in Calva Paredit and it will bind paredit.delete to the backspace key.
Still, I didn’t have time to fix the issues I ran across when I experimented with that newline thing.
that's promising, I will have a look at that after I stop performance tanking on large files then!
I don’t even remember what it was. But I am pretty sure I didn’t see anything suggesting it was a no-go.
Here’s the new dev process, btw: https://github.com/BetterThanTomorrow/calva-fmt/wiki/How-to-Contribute
honestly those are now the only two 'yuck' moments I am having with it, formatting seems to be acceptable for me now using my botched cljfmt and crlf kludge
I haven't tried weavjester's new master actually, but he kept the tests in, so I guess we're free now
Tell me a bit about that idea you had with another take on a formatter, if you have some time.
he basically refactored that #156 patch and my kludge and generally improved the look of things, so yeah 🙂
oh, well it's a bit rough at the moment, honestly I like the idea of using cljfmt or zprint if we can
it was more borne out of frustration from the performance, which I have since discovered is happening on our side, not weavejesters 😉
i even looked at the paredit.js indentation stuff but then discovered it brought us back to terrible cond formatting...
I wonder. When I tried it with only cljfmt involved it got significally slower if I didn’t take care to select only the encosing form for it to format.
I found this https://www.academia.edu/29004707/Incremental_recursive_descent_parsing though
We need to make paredit use calva formatter for it’s indenting rather. It is one reason why I have complicated the dev process so much. 😃
so yeah that paper is interesting- it patches up an AST for an LL(1) parser incrementally, there are various improvements to that but it may be enough. I need to go over it properly but it doesn't seem too crazy to implement
but at the same time, better to use a fast off the shelf formatter if possible so we can concentrate on protorepl awesomeness 😉
On a possibly related note. I have hunted around for a clojurescript paredit. No luck. But in my hunting I found one implementation in Clojure using zippers.
I really want the formatting to just rock though. emacs is the only editor I have ever found acceptable for lisp code so far
I have some old timer's using emacs I work with, so clojure is not a hard sell, but damn, we need a wonderful vscode experience for everyone else 🙂
Yes, I started to do some work with that with the paredit code used in Counterclockwise, but realized I was spreading myself to thin and stopped it.
i thought of some really stupid solutions that are a bit of work but maybe not horrible
One of his ideas was to give us an interface where we fed zprint a zipper. Which makes me think that maybe if we can keep a zipper backing the buffer all the time, and the text mainly is a projection of the zipper, then we would do most everything that way, paredit and formatting included. Maybe parinfer would still be something we didn’t do that way, I don’t know.
actually honestly once cljfmt gets it's edn into a zipper, parinfer should be pretty trivial to implement
it uses https://github.com/xsc/rewrite-clj under the hood to go from source text -> ast
of course we could throw all that away and boot up a jvm clojure in the long run if it made sense in 5 years
well, I find I can generally (require [http://clojure.xxx]) in cljs
It seems to work fine in most cases, but for some configs of shadow-cljs the crash is there.
It is one of the LightTable people who ported rewrite-clj to cljs. Maybe they never added a linter? 😃
Thumbs up on this one, please: https://github.com/clj-commons/wishlist/issues/12
Okay, let me open an issue tomorrow on rewrite-clj
and canvas the idea over there too
I presume you are familiar with https://github.com/clojure-emacs/orchard. Anyhow, I should head out too. 😉
(this is why I wonder if longer term we look at a jvm hosted https://microsoft.github.io/language-server-protocol/overview and strap into that, since all the emacs goodness goes there, and I can try and move a lot of the .el stuff in cider over there ;))