It sounds like a VS Code issue. I would start with looking what had been reported there.
This is probably the same issue as this one: https://github.com/BetterThanTomorrow/calva/issues/971
Please add a comment to that issue @agold
Has anyone figured out how to get the equivalent of emacs' aggressive-indent-mode
? I've set "editor.autoIndent": "full"
but that doesn't seem to be enough. For example:
(foo)
(bar)
;; slurp
(foo
(bar))
;; barf, oh no!
(foo)
(bar)
I'd like it to always always always auto indent no matter what I do, so it's impossible for indentation and code structure to differ
That looks like an issue with the Calva formatter. It focuses on the enclosing form, and runs into troubles at the top level. File it on GitHub, I don't think we ever did that.
funny, I recently asked how to make Calva indenting less aggressive like I'm used to in clojure-mode in emacs :)
ok! I'll make an issue
In general you can find some options here: https://calva.io/formatting/#configuration (@plexus)
btw, pez, the docs are pretty!
@plexus, to verify that I have understood the problem correctly you can try the same procedure with fully enclosed forms.
for me this is really the holy grail, paredit + aggressive-indent, makes me feel like I'm actually manipulating a syntax tree instead of a text file
Yes.
I also want to have one more notch of aggressiveness of the indentation to kick in. I have this feeling it might make parinfer less missed.
I keep some paredit extras here: https://github.com/clyfe/calva-extras
On a similar note I'd like paredit.deleteBackward in the formation " <space> (|)" to delete just the parens first, and on second key press to delete the space; not both at once. Or maybe I'll get used to and will prefer the current beavior.
sorry, got called away for a second. Works fine when it's not at the top level @pez
(do
(foo
(bar)))
(do
(foo)
(bar))
Great. Then it’s not a regression at least. I’m at my computer now and could verify that as well.
> it might make parinfer less missed exactly, I always thought parinfer got it backwards. why manipulate structure via whitespace when you can just manipulate the structure and let the whitespace take care of itself (I'm aware many people will disagree with this sentiment 🙂 )
Parinfer does both, though? Especially if you are furtunate enough to be using an editor that can handle smart mode.
filed an issue https://github.com/BetterThanTomorrow/calva/issues/982
I think the Parinfer preference has a lot to do with personal, yeah, preferences. I was “forced” to think about Clojure code from te structural angle, because I learnt my first Clojure by pair programming with people who were using Emacs and shunned Parinfer. It stuck with me, even with my Python background. Paredit is my buddy. But for some it seems to be second nature (or quickly become at least) to indent their way to structure. I have a new colleague who belongs to that latter category, @anthony-galea. When we pair program I often notice that he accepts quite a lot of work to avoid Paredit. 😃
I have accepted that for some people parinfer works really well, I try to avoid getting into arguments about it, but I can't say I get it. And I strongly resist promoting parinfer for newcomers. If people figure out it works for them ok great, but it's clearly not a great fit for everyone. I've seen too many people (e.g. at clojurebridge workshops) just confuse themselves, accidentally ending up with some weird unexpected structure, and just having no clue how to come back from it.
Yep, I have seen a lot of these problems when learning clojure @plexus
I also avoid promoting Parinfer to newcomers. Of course somewhat because Calva’s auto-formatter does not play well with it, but mostly because I think Paredit is quite easy to learn and learning it helps in figuring out the structured nature of the code. But, yeah, arguing about this is boring. 😃 And, since the VS Code team does not get Parinfer either, Smartmode is not likely to become an option in this editor anytime soon.
but still I find calva very good to work with as a beginner
made even my first web project with it
The aspects I am interested in is mainly when Parinfer speeds up an operation. When I watch it being used I notice both that it is slower and that is faster than Paredit. I haven’t quite wrapped my head around it, but when I do I will try to use the understanding to make Calva editing more efficient.
I saw that. 😃 Noticed that you have commited a lot of tempfiles produced by Calva, clojure-lsp and clj-kondo. Which reminds me that Calva should help with avoiding that.
oke
now im stuck because I thought of a way to use pre-loading but get a error message which do not tell where the error is
pre-loading of what?
that I find a bummer about clojure. the error messages that are nor clear
pre-loading of some images from a external api
but this is off-topic of this channel
Since we’re in a thread we can go off-topic, me thinks. 😃 Not sure if this is useful to you, but in my Advent of Code util.clj
I cache my input data using memoize
:
(defn- fetch-input' [day]
(try
(let [cookie (slurp ".aoc-session")]
(:body (client/get
(str "<https://adventofcode.com/2020/day/>" day "/input")
{:cookies {"session" {:value cookie}}})))
(catch Exception e
(println "Ho, ho, ho! Did you forget to populate `.aoc-session` with your AOC session cookie?")
(throw e))))
(def fetch-input
(memoize fetch-input'))
Maybe images are not something that should be memoized.it worked before
Agree about error messages and stack traces often being less helpful than we have in other languages. But you will get better at recognizing the patterns, so the problem will not remain this big for you.
but I think this line mess things up
(future (memo-display-data (inc page))
but to get more info, I begin a question on the beginners question where you can find all the data
Yeah #beginners is the place for this. I don’t have much experience with futures anyway. 😃
NP
maybe someone else can see what is wrong
Im just a beginner which have to learn a lot
I think I saw an API key in your repo, btw. You might want to not have that public.
yep, I still have to learn how to hide it
but is a key from a company which do not exist anymore
One way is the way I do it in the util code I posted above. Then I have .aoc-session
in .gitignore
.
oke
so like this :
{:cookies {"session" {:value cookie}}})))```
I have to think well how I can make that work
It’s is rather this:
(let [cookie (slurp ".aoc-session")]
oke
and in the file .aoc-session I can put the key?
easy fix then , which I would do after I get this working again
Yes, put the key in some file that is gitignored, then read it in. You can make a memoized function that does the reading, so that the server doesn’t read the file every time.
Also, you might want to use <http://clojure.java.io/resource|clojure.java.io/resource>
to predictably find the file: https://clojuredocs.org/clojure.java.io/resource
oke, fix on my list
like I said first I want to make the site running again
Also put on that list to change the key. 😃
and then practice more with 4clojure and exercism
and learn re-frame so that I can make the next idea I have for this site
so enoughh to learn this year
and maybe even try some AOC challenges after exercism and 4clojure
Good plan! I think Exercism should suit you very well, since you like getting feedback. It helped me tons and tons. There’s #exercism , btw.
yep
I’ve commented on the issue with top level formatting. Could be interesting reading for anyone who is curious about the innards of Calva structural editing: https://github.com/BetterThanTomorrow/calva/issues/982
I think there are a lot of quite interesting things with Calva structural editing that I could write some articles about, btw. I might even start that soon. 😃
Here’s a VSIX with a fix for the ;
line comment bug that hits some of you. It might also fix the issue that @agold had with auto-closing quotes. Please try it out, Calva friends.
what's the shortcut key for closing a tab in calva (ctrl w is taken)
You'll have to assign a shortcut, @kbosompem . At least until we update the Calva shortcut.
Toying with https://nextjournal.github.io/clojure-mode/ Nifty how modifier key highlights the form to be repl-sent.
@pez Worked like a charm! Many thanks!
Don't think it's possible with vscode, but would be so sweet!
Hi 👋:skin-tone-2: is it possible to define keybindings for certain repl-commands? I would like to have a keybinding that would tap>
the form I’m evaluating. I noticed there is setting for calva.customREPLCommandSnippets
but I think I cannot pass args to those snippets
I think it should be solved with those command snippets. We recently pulled a PR that adds some editor variables to those snippets. Sounds like if we add variables for the current form and current top level form, we would handle this case. You think so too, @janne.sauvala ?
Yes, that could work. I got the idea from Sean Corfield’s setup with vscode+Clover. And your suggestion could be how Clover handles custom command integration with the editor 👍:skin-tone-2:
I guess allowing params would make it way more extensible. Also if it seems many users are using the same custom command, maybe it's a candidate for a built-in command.
I just re-read what @pez said and I'm not sure it hit me the first time. That sounds like a great idea. :simple_smile:
I finally made an issue for tracking purposes https://github.com/BetterThanTomorrow/calva/issues/986