This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-02
Channels
- # beginners (29)
- # cider (41)
- # clara (1)
- # cljs-dev (17)
- # cljsrn (1)
- # clojure (158)
- # clojure-dev (2)
- # clojure-dusseldorf (2)
- # clojure-italy (8)
- # clojure-mexico (1)
- # clojure-russia (2)
- # clojure-spec (43)
- # clojure-uk (1)
- # clojurescript (44)
- # community-development (98)
- # cursive (9)
- # data-science (8)
- # datascript (4)
- # datomic (30)
- # emacs (6)
- # fulcro (11)
- # graphql (6)
- # jobs (1)
- # jobs-discuss (27)
- # lein-figwheel (5)
- # luminus (13)
- # lumo (4)
- # off-topic (28)
- # onyx (9)
- # parinfer (12)
- # perun (2)
- # portkey (5)
- # re-frame (48)
- # ring (2)
- # shadow-cljs (52)
- # spacemacs (29)
- # tools-deps (15)
- # unrepl (9)
- # vim (7)
- # yada (3)
Hey. Is there a way to configure specific indentation rules for macros? Right now I'm writing some rest services using compojure-api and this is what I end up with
(context "/api/v1/accounts" []
:tags ["Accounts"]
(GET "/" []
:summary "Retrieves all accounts"
(ok (accounts-repository/all)))
(POST "/" []
:return Account-Response
:body [acc Account]
:summary "Create an account"
(ok (accounts-repository/insert acc)))
(context "/:account-id" []
:path-params [account-id :- s/Int]
(GET "/" []
:summary "Retrieve account by id"
(ok (accounts-repository/find-by-id account-id)))
(context "/transactions" []
(GET "/" []
:summary "Retrieve transactions for account"
(ok (transactions-repository/all)))))))
what I would like is this indentation style:
(context "/hello-async" []
(resource
{:coercion :spec
:get {:parameters {:query-params (s/keys :req-un [::name])}
:responses {200 {:schema (s/keys :req-un [::message])}}
:handler (fn [{{:keys [name]} :query-params}]
(a/go
(a/<! (a/timeout 500))
(ok {:message (str "Hello, " name)})))}}))
is there a way to do this?Does this help? https://github.com/clojure-emacs/cider/blob/master/doc/indent_spec.md
I have no experience with this, but i stumbled across the docucentation. Perhaps it helps.
IIRC, the indent spec is for when you're the author of the macro. Otherwise, use indentation overrides for clojure-mode
, as documented here:
https://github.com/clojure-emacs/clojure-mode#indentation-options
For example, I have this in my dotspacemacs/user-config
, for using speclj for testing:
(with-eval-after-load 'clojure
(define-clojure-indent
(describe 1)
(context 1)
(it 1)
(with 1)))
@jeff.terrell Ah ok, sorry for pointing in a wrong direction…
Ha, no worries, it's an easy mistake to make.
Besides, better to try and fail than not to try, right?
Yeah, but obviously it had nothing to do with CIDER, but clojure-mode, so i had the wrong association. Nice you are into that stuff ☺️
Thanks, that does look like what I need. I'm having problems getting it to work though... I've added this into my user-config
section:
(with-eval-after-load 'clojure
(define-clojure-indent
(->> 1)))
but this macro is still being formatted as usual
(->> a
b)
any ideas? I'm kinda new to spacemacsTry it in the ex-mode line while editing a Clojure buffer, e.g. :(define-clojure-indent (->> 1))
from normal mode.
(I'm assuming you're using vim-style editing, i.e. "evil mode" in Spacemacs, btw.)
Then go to the beginning of your ->>
expression and type =%
to indent according to the current rules.
yeah. I've added some printing inside with-eval-after-load
call to make sure the code was not called
@lemons - I'm not sure, but I wonder if clojure-mode
is only loaded once, when a clj file is first encountered.
So yeah, to tag on what @spfeiffer said, if you restart spacemacs and load a clj file, is the with-eval-after-load
code still not being executed?
(with-eval-after-load 'clojure-mode <----
theres apparently two different packages/libraries/whatever this thing is in emacs. clojure-mode is the one I neededAh, didn't notice that, but it's obvious in retrospect, isn't it? Glad you got it figured out.