Fork me on GitHub

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?


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


Thanks! So the recommendation is to not use it?


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.


Somehow, after being a longtime vscode user, I just found out about! 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?


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.


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


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


@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?


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


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


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


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

👍 3