This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-01-23
Channels
- # announcements (2)
- # babashka (56)
- # beginners (30)
- # calva (79)
- # cider (5)
- # circleci (3)
- # clj-kondo (84)
- # cljfx (2)
- # cljsrn (3)
- # clojure (264)
- # clojure-czech (3)
- # clojure-europe (18)
- # clojure-spec (3)
- # clojurescript (12)
- # conjure (28)
- # cursive (5)
- # datomic (4)
- # deps-new (22)
- # fulcro (6)
- # graalvm (3)
- # jobs (1)
- # malli (1)
- # off-topic (23)
- # pathom (4)
- # portal (3)
- # practicalli (2)
- # quil (6)
- # reagent (20)
- # remote-jobs (3)
- # reveal (14)
- # ring (10)
- # shadow-cljs (5)
- # spacemacs (4)
- # xtdb (4)
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 :)
In general you can find some options here: https://calva.io/formatting/#configuration (@plexus)
@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
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.
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.
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.
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.
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
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 " " 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.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 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. 😃
One way is the way I do it in the util code I posted above. Then I have .aoc-session
in .gitignore
.
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
to predictably find the file: https://clojuredocs.org/clojure.java.io/resource
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.
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’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.
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.
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 don't think it's possible currently. I think this may be best done with a new Calva command. Feel free to file an issue for a feature request.
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, @UJZ6S8YR2 ?
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.
I finally made an issue for tracking purposes https://github.com/BetterThanTomorrow/calva/issues/986