This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-12-16
Channels
- # adventofcode (24)
- # announcements (3)
- # aws (3)
- # babashka (16)
- # beginners (88)
- # biff (5)
- # calva (27)
- # cider (15)
- # cljs-dev (70)
- # clojure (87)
- # clojure-austin (3)
- # clojure-belgium (6)
- # clojure-europe (59)
- # clojure-nl (1)
- # clojure-norway (14)
- # clojure-uk (3)
- # clojurescript (37)
- # data-science (2)
- # datalevin (40)
- # datomic (1)
- # emacs (23)
- # events (2)
- # graalvm (13)
- # graphql (7)
- # gratitude (1)
- # holy-lambda (193)
- # inf-clojure (15)
- # lsp (27)
- # malli (9)
- # off-topic (20)
- # polylith (6)
- # reitit (29)
- # releases (2)
- # scittle (13)
- # shadow-cljs (51)
- # transit (15)
- # xtdb (29)
If I have
(foo
(bar baz))
and I want
(bar
(foo baz))
what's the best way of going about it? transpose-sexp
isn't quite right, and neither is paredit-splice-sexp-killing-backward
or paredit-raise-sexp
(since both are destructive)awesome, thanks. Strange to me that the point has to be on b
specifically, e.g. if it's on the a
of baz
I get (bar b (foo az))
. But I can totally work with that, thank you!
ah, that doesn't happen with smartparens. I'm not sure which one is right. glad that's helpful
Dear lazyweb. We have some macros which we’ve annotated with
{:style/indent 1}
Sometimes(TM) this is honored by my emacs, other times it is not.
It seems to be honored when I manually use TAB
to indent, but when eg slurp
ing and barf
ing with paredit (which causes reindentation) the :style/indent
seems not to be honored.
I use Clojure mode and clojure-lsp.
I’m not asking for a full debug of this, I’m just sort of curious if eg clojure-lsp doesn’t honor the :style/indent
or something?Never heard about that 😅 even so, clojure-lsp delegates format to cljfmt, so it should be supported there (if it really makes sense)
@UKFSJSM38 just in case, :style/indent is a CIDER thing. But it's pretty easy to translate from its format (https://docs.cider.mx/cider/indent_spec.html) to cljfmt's. So it's something clojure-lsp could do by analyzing the defmacros in the codebase, fetching all this metadata and then invoking cljfmt with this dynamically-built config That way, both worlds would be bridged
I’d nuance it a bit. I believe style/indent
originated with CIDER, but the hope/intent was that it would be a cross IDE/formatter/whatever way to express indentation needs.
> Issue been open since 2015 yeah I doubt it will be fixed from their side - analyzing var metadata surely exceeds cljfmt's intended scope so either cider or clojure-lsp would do it
@U0BKWMG5B seemed positive to the idea, but was lacking time?
the issue with that is that clojure-lsp just pass the string to cljfmt, if we need to parse it and check every call macro, get kondo analysis for that and check if has metadata would probably affect performance and since format is something that is called automatically in some editors it needs to be fast :/
> the issue with that is that clojure-lsp just pass the string to cljfmt, if we need to parse it and check every call macro, get kondo analysis for that and check if has metadata would probably affect performance and since format is something that is called automatically in some editors it needs to be fast :/
I'd assume this can be cached like various other things in lsp?
In CIDER it's fast becase it's runtime-powered, but we also could/should cache it for offline invocation.
...The key insight is that if you believe that :style/indent
is useful, generally you have to perform some analysis. Under the clojure-mode/cider/style-indent philosophy, formatting isn't something homogeneous/mechanical (a la Tonsky), but codebase-specific.
So, yes, there's no speedy formatting without caching or some other 'cheating' (runtime introspection) - CIDER users have lived under this constraint/tradeoff for years and it has worked perfectly :)
> supporting that on cljfmt would probably be the best as it already parses the node Sounds pretty neat, however it misses metadata mutation performed via other means
caching does not help that much here as user keeps changing the code, so we need to re-analyze the clojure and invalidate the cache. I can see how convenient it is to support that for the final user, would be perfect to have that on cljfmt IMO, but we could start with a issue on clojure-lsp to discuss more about it, maybe we can find something in between that could work.
Will create it - good timing (just joined a lsp-heavy job with cljfmt also in the mix 😃)