Fork me on GitHub
#lsp
<
2022-03-26
>
ericdallo14:03:28

clojure-lsp Released https://github.com/clojure-lsp/clojure-lsp/releases/tag/2022.03.25-12.02.59 with lots of improvements! • General ◦ Fix cljfmt settings merge during refresh/classpath configs merge to avoid multiple config vectors on same symbol. ◦ Fix install script for aarch64. https://github.com/clojure-lsp/clojure-lsp/issues/794 ◦ Fix handling cljfmt config files that end in .clj https://github.com/weavejester/cljfmt/issues/190 ◦ parser: more efficiently seek to cursor position, improving performance especially in large files. https://github.com/clojure-lsp/clojure-lsp/pull/793 https://github.com/mainej ◦ Fix clean-ns not sorting properly node requires for cljs. https://github.com/clojure-lsp/clojure-lsp/issues/815 ◦ Fix move-to-let to ensure locals don't move out of scope. https://github.com/clojure-lsp/clojure-lsp/issues/830 ◦ Improve logic around require suggestions. https://github.com/clojure-lsp/clojure-lsp/issues/837 ◦ Enhance move-to-let to introduce and expand let if an existing one doesn't exist. https://github.com/clojure-lsp/clojure-lsp/issues/829 ◦ Bump org.clojure/clojure to 1.11.0. ◦ Fix move-coll-entry to maintain cursor position instead of a range. https://github.com/clojure-lsp/clojure-lsp/issues/862 ◦ Clean ns automatically after adding missing require/imports, enabled by default under new :clean :after-ns-refactor flag. https://github.com/clojure-lsp/clojure-lsp/issues/558 • Editor ◦ extract-function: Fix wrong args when extracting from multi-arity fn. https://github.com/clojure-lsp/clojure-lsp/issues/683 ◦ extract-function: Fix wrong args when extracting after a local usage. https://github.com/clojure-lsp/clojure-lsp/issues/812 https://github.com/mainej ◦ move-coll-entry: clauses move intuitively in assoc, case, cond, and similar functions. https://github.com/clojure-lsp/clojure-lsp/pull/780 https://github.com/mainej ◦ move-coll-entry: fix NPE when when invoked from top-level https://github.com/clojure-lsp/clojure-lsp/issues/803 https://github.com/mainej ◦ Generate stubs async after startup, improving startup time. https://github.com/clojure-lsp/clojure-lsp/issues/788 ◦ Improve and add lots of new snippets following practicalli config. https://github.com/clojure-lsp/clojure-lsp/issues/797 ◦ Improve how watched new files are analyzed avoiding infinite loops and performance issues. https://github.com/clojure-lsp/clojure-lsp/issues/796 ◦ Avoid infinite loops when several files are changed simultaneously. https://github.com/clojure-lsp/clojure-lsp/issues/796 https://github.com/mainej ◦ Fix "incoming call hierarchy" not considering usages inside defmethods. https://github.com/clojure-lsp/clojure-lsp/issues/808 ◦ range-formatting: more efficiently locate extent of range and reduce number of calls to cljfmt, improving performance especially when formatting large ranges. https://github.com/clojure-lsp/clojure-lsp/pull/795 https://github.com/mainej ◦ cycle-fn-literal: new feature convert between function-literal syntaxes (fn [] ...) <-> #(...). https://github.com/clojure-lsp/clojure-lsp/issues/774 ◦ Add find-implementation feature to defmulti and defmethod. https://github.com/clojure-lsp/clojure-lsp/issues/751 ◦ Make find-implementation of defprotocol names find its implementations and find-implementation on deftype/`defrecord` methods find other implementations. ◦ Add new code action Introduce let for existing command. https://github.com/clojure-lsp/clojure-lsp/issues/825 ◦ Make find-implementations consider reify. https://github.com/clojure-lsp/clojure-lsp/issues/827 ◦ Fix namespace on file creation when nested source-paths are available. https://github.com/clojure-lsp/clojure-lsp/issues/832 ◦ unused-public-var: fix to show warnings on vars defined with declare. https://github.com/clojure-lsp/clojure-lsp/issues/840 ◦ unused-public-var: large performance improvements, especially for large projects. https://github.com/clojure-lsp/clojure-lsp/pull/861 https://github.com/mainej • API/CLI ◦ Extract lsp4clj as a seperate library. https://github.com/clojure-lsp/clojure-lsp/issues/807 https://github.com/Cyrik Supported by https://www.scarletcomply.com/ ◦ Fix inconsistency with clean-ns/format not copying kondo configs. I'd like to thank @jacob.maine and @domagala.lukas for their contribution making clojure-lsp even better! opensource This release has a lot of performance improvements, especially related to unused-public-var linter that is incredibly faster now thanks to @jacob.maine’s work 👏 This certainly improves startup time and reduce cpu a lot. We know have a lot of new snippets following @jr0cket’s suggestions, thank you for that! A new asked feature is available too! Find implementations of defmultis ! And lots of other improvements/fixes, hope all of you like it! 🚀

🎉 15
clojure-lsp 6
practicalli 3
clj-kondo 4
dharrigan17:03:05

That cycle-fn-literal is sweet

dharrigan17:03:11

Could I go over something, is this no longer valid? #_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}

dharrigan17:03:27

I'm getting a diagnostic hint that the function below it is not used

ericdallo17:03:44

This should still be valid

dharrigan17:03:51

Not anymore it appears

ericdallo17:03:19

yeah, I confirmed the issue

dharrigan17:03:20

Before I wasn't getting the hint warning. Trying out the new version before pushing to arch and it's now flagging this

ericdallo17:03:54

let me take a look

ericdallo17:03:23

I know what it is, will open a new thread

dharrigan17:03:37

or, just tranfserr to github issue

dharrigan20:03:19

sweet, having a looksee

dharrigan20:03:20

Yup, all good

ericdallo20:03:00

good, thank you!

dharrigan20:03:51

you're most welcome! Thank you for fixing it quickly 🙂

👍 1
ericdallo17:03:44

Unused public var bug 🧵

ericdallo17:03:40

@U04V15CAJ @U11EL3P9U reported that

#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
(defn foo [a]
  1)
doesn't work anymore, after some digging I think it's related with a existing bug that was not present because we lint async the custom-lint and know we rely on kondo reg-finding! used during custom-lint

ericdallo18:03:48

will do a quick fix making it async so we can fix it on clj-kondo later carefully

👍 1
ericdallo18:03:37

Well, is not that easy to fix that on clojure-lsp, so @U04V15CAJ I know you are busy with the windows issue, so I could try to fix it on clj-kondo, the issue seems to be that reg-finding https://github.com/clj-kondo/clj-kondo/blob/master/src/clj_kondo/core.clj#L205 doesn't handle-ignore properly

ericdallo18:03:30

so not sure how we could fix that behavior

ericdallo18:03:26

I think this used to work by luck on clojure-lsp because we async lint that not using reg-finding before

ericdallo18:03:10

Oh, sorry, the issue seems on clojure-lsp side, clj-kondo there is even a test for that, I think I found the issue, will work on a fix

ericdallo18:03:54

@U11EL3P9U could you try changing your .lsp/config.edn :linters :clj-kondo :async-custom-lint? to false ? or just try latest #clojure-lsp-builds

ericdallo18:03:32

I think with recent changes and improvements we don't need that flag anymore, but for now will do a quick fix changing that flag default to false

ericdallo18:03:07

Releasing the fix...

dharrigan20:03:38

Hi. Just back

dharrigan20:03:10

Yup, changing that setting to false restores behaviour

ericdallo20:03:19

Good, the release is almost done

jacob.maine21:03:26

@UKFSJSM38 is this something you’d like help with? Or do you have it handled?

ericdallo21:03:55

@jacob.maine for now it's fixed, but we should either remove async-custom-lint? or make it work without those issues, with the improvements we have, we could probably remove it, but I'm afraid huge files with lots of var-definitions could be affected

jacob.maine21:03:16

Yeah, I figured you’d left it in place for really huge files. When you have a chance, will you explain why making it async fixes things? I don’t really understand how reg-finding! works differently in the sync and async versions

ericdallo21:03:10

Actually, before the huge performance improvements I did that custom linter be async, which doesn't block the rest of lint, that worked and was helpful until we fix performance with this release, now it's not necessary, the code is complex and now causes this bug :), so maybe removing makes sense, we jsut need to make sure the performance is still good for huge files with multiple definitoins and references

jacob.maine21:03:23

Gotcha. If we can remove it that’d be ideal. If not, I’d like to understand how things work. To be honest I’ve never understood how reg-finding! works with an async custom linter. How does clj-kondo know the custom linting is done? My working hypothesis has been that reg-finding! actually doesn’t matter when the linter is async. Instead of waiting for clj-kondo to return us back our own findings, we publish them straight to the client. Is that right?

borkdude21:03:52

You can do anything you want in the custom-lint-fn, reg-finding will just take care that whatever you do there will be part of the :findings returned by clj-kondo itself

borkdude21:03:10

but if you're not going to use those, then you don't have to call reg-findings! there of course.

borkdude21:03:47

so you could launch an async thread/future/whatever in the custom-lint-fn and just do your own thing with the analysis

jacob.maine21:03:19

@U04V15CAJ I imagine that if you call reg-findings! asynchronously, it’s too late for those findings to be included in clj-kondo’s analysis… clj-kondo will already have returned, right?

borkdude21:03:52

that's true

jacob.maine21:03:11

That’s what I figured. Just wanted to be sure.

borkdude21:03:25

but you could trigger the updating of clojure-lsp's idea of findings in there

borkdude21:03:08

you will just have to keep track which are the most recent / valid findings yourself

jacob.maine21:03:17

> trigger the updating of clojure-lsp’s idea of findings

jacob.maine21:03:19

Yeah, I think that’s what clojure-lsp is doing, or at least what it’s intended to do. This bug suggests maybe that isn’t really working

borkdude21:03:20

e.g. using a correlation id or so

ericdallo21:03:51

That's what clojure-lsp used to do when async

jacob.maine21:03:01

Right… there are lots of subtle timing bugs we haven’t quite worked out

ericdallo21:03:19

Yes, IMO doing it sync is way easier and less error prone

borkdude21:03:45

now it's super fast right?

jacob.maine21:03:45

Definitely, but in the case of your giant Nubank file, which still takes 5 seconds, I can imagine that it’d be nice to start other things like symbol highlighting before the linting is done

ericdallo21:03:23

Actually, it takes 3s the whole project, I'll test the biggest file to make sure it's still fast

👍 1
ericdallo21:03:34

Symbol highlight before lint is dangerous, we may show outdated highlight, we need to wait for kondo analysis to reliable show that

jacob.maine21:03:59

Gotcha. Maybe that’s a bad example

jacob.maine21:03:51

As I’m testing this stuff I keep adding and removing duration logs around custom linting for a single file. Maybe we should add them temporarily until this feature has settled.

👍 1
dharrigan22:03:41

Just spotted something else.., I don't think it's pulling in the refer correctly as part of the code action.

apt23:03:47

Just out of curiosity, what are you using for getting the minibuffer stuff in this position?

👍 1
dharrigan06:03:21

My setup is neovim + coc + conjure and coc-clojure. You can find it all here . Enjoy!

💯 1
dharrigan22:03:20

Is it meant to add in intersection for option 2?

ericdallo22:03:24

yes, probably related with recent changes c/c @U0BUV7XSA

snoe22:03:00

yup, got a fix for that on the way

🤞 1
dharrigan22:03:36

you guys are super awesome! Anyhoooo, off to bed, ttfn!