Fork me on GitHub
#calva
<
2021-08-22
>
raicotop06:08:31

Hi, I have a problem formatting this code block (taken from @yogthos' book):

(defn create-user!
  [login password]
  (jdbc/with-transaction [t-conn db/*db*]
    (if-not (empty? (db/get-user-for-auth* t-conn {:login login}))
      (throw (ex-info "User already exists!"
                      {:pietrail/error-id ::duplicate-user
                       :error "User already exists!"}))
      (db/create-user!* t-conn
                        {:login login
                         :password (hashers/derive password)}))))
When I press TAB, this message appears:
Running the contributed command: 'calva-fmt.formatCurrentForm' failed.
This happens when I use this additional formatting option:
{:align-associative? true}
Once I switch this option to false, no problem (but it doesn't format the way I would like to). Is this a calva issue, or a cljfmt issue?

pez20:08:12

It’s a Calva issue. The {:align-associative? true} is an experimental addition to cljfmt

raicotop15:08:08

Thanks! So the recommendation is to not use it?

pez15:08:28

Yes, I recommend not using the setting, and instead doing it on demand, with the separate command, which is named something like Format and Align Current Form. Default shortcut is ctrl+alt+l. Though I have to also warn that we are considering removing the feature fully. It is causing confusion and troubles. I am figuring if I can support it on-demand somehow anyway, without having it as an option for the formatter.

Max20:08:37

Somehow, after being a longtime vscode user, I just found out about https://code.visualstudio.com/blogs/2018/07/12/introducing-logpoints-and-auto-attach! It’d be great to have support built into calva, especially if forms, rather than lines, could be instrumented. Might also be an interesting usecase for tap?

pez20:08:57

Indeed. I am a heavy user of logpoints whe coding in TypeScript. Not sure how hard it would be to add it to Calva, but please file a feature request about it.

ericdallo23:08:40

Probably built-in if using DAP (Debugger adapter protocol), but AFAIK Calva use cider debugger which doesn't follow that protocol, not sure it's possible without that, maybe there is a way somehow

pez06:08:11

It would be very sweet being able to both debug print and to tap stuff this way.

bringe00:08:00

@UKFSJSM38 Calva's debugger uses the DAP, we just use cider-nrepl in conjunction with it. Did you mean some specific way of using the protocol or a specific feature?

ericdallo00:08:23

Oh, I didn't know it was following DAP, what is the DAP server you use as a DAP client?

ericdallo00:08:20

So that is the DAP client for VSCode, I suppose the DAP server is from cider?

ericdallo00:08:44

I mean, it's similar to LSP, there is a client and a server, the server is where the logic of breakpoints, threads etc and just tell the client how to behave

ericdallo13:08:05

Oh, that's interesting, I will take a look

👍 3