Fork me on GitHub
#lsp
<
2023-01-25
>
Braden Shepherdson17:01:32

just posted https://github.com/clojure-lsp/clojure-lsp/pull/1471 to add :style/indent support. it works great, and it has negligible performance impact even when I run against Metabase.

ericdallo17:01:21

Awesome, will take a look!

Braden Shepherdson17:01:37

I'm fixing the lint etc.

Braden Shepherdson17:01:14

LMK what you think about the approach to conversion; it's kind of fiddly.

👍 2
ericdallo17:01:26

@U45T93RA6 may be interested in that

Braden Shepherdson18:01:35

ah, a possibly-controversial point I just noticed. :style/indent is nominally only supported for macros, and the PR respects that. but cljfmt doesn't care and there are lots of useful :style/indents in the wild on defns too. one example is Toucan, to get nice

(db/update! SomeModel id
  :field 7
  :other_field "bar")

ericdallo18:01:28

I'm ok supporting it for functions, I can't see how one would add a :style/indent accidentally if not for that purpose

👍 2
Braden Shepherdson18:01:30

agree. my only concern is that they're not namespaced 😞 cljfmt is too naive to understand an indent spec for 'toucan.db/insert! should be used when (:require [toucan.db :as db]) (db/insert! ...)

😭 2
ericdallo18:01:53

yeah, good point

ericdallo18:01:37

if the classpath has 2 functions of different ns with same name and both with style/indent, one of them would use the wrong style/indent right

Braden Shepherdson18:01:53

yeah, that's correct.

Braden Shepherdson18:01:21

the Right Answer is probably to make cljfmt smart enough to understand ns aliases, then it would work unless you :refer or :use.

ericdallo18:01:09

yes, so maybe we should start with only macros support for now?

ericdallo18:01:18

but would be nice to address a issue on cljfmt about that

Braden Shepherdson18:01:39

SGTM. I'll look into that as a PR today too; hopefully it's not too hard.

Braden Shepherdson18:01:02

how about I future-proof the PR by making it use macros unqualified, and functions qualified?

ericdallo18:01:25

hmm, since cljfmt doesn't support that and we don't even know if is easy or even possible I wouldn't suggest do this premature optimization, we could easily change that later after cljfmt changes

vemv21:01:29

Thanks for the ping! Awesome stuff. Stupid q, is a dynamic require like a top-level (require '[foo.bar :as f]) accounted for?

ericdallo21:01:48

AFAICS it should work for that as well

ericdallo21:01:56

@UCY0GT0QM I'm about to release a new clojure-lsp version tomorrow, but I'd like to leave this PR for the next one if you don't mind since I'd like to test it in the master a little bit more regarding perf/any issues we may face

Braden Shepherdson21:01:07

sounds good. I can use my local build in the meantime anyway.

ericdallo21:01:51

Or use a nightly one from #C032YH7P0R2 (compiled with graal) Sounds good, LMK if you will address vemv suggestions or if it's read to one last check

Braden Shepherdson00:01:20

@UKFSJSM38 thoughts on just including the non-macros, with namespacing? it's a tiny change to LSP. we can avoid the need for the cljfmt fix in most cases with (update cljfmt-config :alias-map not-empty), since it's nearly always {}.

ericdallo00:01:01

Yeah, sounds like it's worth, go ahead