Fork me on GitHub
#calva
<
2021-04-08
>
pdekruif07:04:37

Hi all, could someone offer me some insight in formatting? I'm using Calva's builtin formatter which works well, but I also have coworkers using emacs and cursive. We're trying to uniform the formatting that we're using. I've looked at cljfmt and cljstyle, but those don't seem to support map column alignment (which Calva and Cursive both do support, don't know about emacs). Having a single tool (like clj-kondo) to do the job would be ideal, so we can enforce that with git / CI. Hope this is the right place to ask this question. Is this something other teams ran into? What options are currently available to solve this? Any suggestions would be greatly appreciated, thanks!

borkdude07:04:58

@pdekruif clj-kondo is not a formatter. have you looked at zprint as well?

pez07:04:56

The issue was brought up as late as yesterday, so it is definitely something teams run into. It is also a really tricky thing to solve as this ClojureVerse (including all the links) demonstrates: https://clojureverse.org/t/clj-commons-building-a-formatter-like-gofmt-for-clojure/

pez07:04:27

I think that for teams aligning around cljfmt defaults make sense. Not only because that is Calva’s defaults. Aligning maps and stuff is nice, but simplifying the unification across the team is nicer.

👍 1
pdekruif07:04:35

@borkdude clj-kondo is not a formatter I know, I meant it's such a great (standalone) tool that can be used as a quality gate and with whatever editor. Thanks for all the hard work you're doing on that! We'd like to use something in the same way, but for formatting. I'm looking at zprint right now per your suggestion and it looks definitely promising. Thanks!

pdekruif08:04:27

@pez is it possible to use the cljfmt variant of Calva as a standalone tool? Calva uses it's own fork from cljfmt right?

pez08:04:52

I think so. Building the jar from the fork should do it.

pez08:04:06

It’s an aging fork, though. We will have to merge form latest cljfmt soon.

pdekruif09:04:39

zprint looks pretty good for our purposes. currently I have format on save enabled, which uses Calva's cljfmt. Is it possible to switch this out for zprint? Here be dragons?

pez09:04:26

Not really. But Calva could be made to support using either cljfmt or zprint as the formatter. It would take quite a lot of work, but it is a possibility at least.

pez09:04:55

If you standardize along formatting that Calva can’t be configured to support, then format-on-save will cause more pain, I think. Depending on how you enforce your formatting, of course.

pdekruif09:04:31

Good to know. I'll try with this plugin alongside Calva: https://marketplace.visualstudio.com/items?itemName=SteefH.external-formatters . I've disabled Calva format, see how that works out. In case anyone is interested, I've added this to my settings.json:

"externalFormatters.languages": {
    "clojure": {
      "command": "zprintm",
      "arguments": []
    }
  },
  "[clojure]": {
    "editor.defaultFormatter": "SteefH.external-formatters"
  }

👀 1
pez12:04:24

Dear Calva ClojureScriptarians I just got word from @bozhidar that in cider-nrepl 0.25.10 the completion of JS things is re-enabled unless it’s a shadow-cljs REPL (because it doesn’t work there yet). Please update your Calva jack-in dependencies settings to try it out. Let us know if you run into issues.

❤️ 2
pez12:04:26

If you are not following along in the #lsp channel (which you should) you might not know that 2021.04.07-16.34.10 was released yesterday. Same there, please try it out and give feedback where you think it is appropriate.

thanks 1
pez12:04:43

And in both cases, remember that you have fiddled with this settings, so that you can reset it to defaults later and follow Calva’s choice of dependencies as we update them.

Setzer2212:04:04

Hi there! Is there a way in calva to evaluate a whole file? Similar to CIDER's cider-eval-buffer

pez13:04:48

@setzer22: The closest you’ll get is Load Current File and Dependencies, which might be close enough. You can also Select All -&gt; Evaluate Current Form (or selection, if any), then Undo Cursor. Which on mac, default key bindings, would be cmd+a ctrl+enter cmd+u.

pez23:04:21

Would appreciate some help testing a VSIX again: https://12713-125431277-gh.circle-artifacts.com/0/tmp/artifacts/calva-2.0.186-1023-add-comment-context-d9c37682.vsix It introduces these changes: • https://github.com/BetterThanTomorrow/calva/issues/1023 • Fix: https://github.com/BetterThanTomorrow/calva/issues/1105 It also uses these new contexts to let VS Code default word movement be active within line comments. Please consider giving it some spins both to check the new functionality and to help find any regressions we might have introduced. (“We” are @cb.lists and yours truly in this case.)

pez23:04:59

@U0N9SJHCH, since you are running with the unbalanced closing brackets prevention thing enabled, maybe you can test this one and confirm that it behaves better in line comments now?