Fork me on GitHub
#lsp
<
2022-05-03
>
ericdallo14:05:40

clojure-lsp Released clojure-lsp 2022.05.03-12.35.40 with mostly really important performance improvements! 🚀 • General ◦ Bump clj-kondo to 2022.04.26-20220429.192438-2. ◦ Decrease uncached startup time by 60-70%, by instructing clj-kondo to skip var definition bodies when analyzing deps. https://github.com/clj-kondo/clj-kondo/pull/1674 ◦ Improve speed of alias/ns completions. ◦ Change alias/ns completions to return a label that matches the input. ◦ Support sorting classes inside package imports during clean-ns. https://github.com/clojure-lsp/clojure-lsp/issues/932 ◦ Avoid saving duplicate source-paths, not calling clj-kondo to analyze same filenames multiple times, improving startup speed. ◦ Improve progress report both on editor and CLI using new clj-kondo callback feature. • Editor ◦ Support workspace/willRenameFiles, renaming namespaces and all its references when a file is renamed. ◦ Don't save cache when classpath lookup failed. ◦ Wait for editor to apply edits before requesting cursor re-positioning. Fixes cursor positioning after drag in Calva. ◦ drag: Request edit only of changed clauses, not entire parent, reducing flicker. • CLI/API ◦ Bump lsp4clj to 0.3.0. The most important changes are performance, lots of improvements regarding completion and startup time, with @jacob.maine's help we now scan classpath way faster. We improved how clojure-lsp update the progress bar both on CLI and on editors, showing a way more precise percentage when starting server! Also, we have a long waited new feature: support for when renaming files in editor, update namespace name and all references to it! This already worked if you rename the namespace using LSP rename, but now following new LSP spec we made it work if renaming files in editor as well! This release was supported by https://www.clojuriststogether.org/ clojurists-together gratitude

🎉 10
gratitude 1
dharrigan14:05:53

Just tried to do a rename file with neovim and coc, it no work 😞 I see the output in that CoC is sending a workspace/willRenameFiles with the old and the new, but the response back from clojure-lsp is documentChanges [] Details in thread:

dharrigan14:05:08

[Trace - 15:54:52] Sending request 'workspace/willRenameFiles - (8)'.
Params: {
    "files": [
        {
            "oldUri": "file:///home/david/tmp/foo/foo.clj",
            "newUri": "file:///home/david/tmp/foo/bar.clj"
        }
    ]
}


[Trace - 15:54:52] Received response 'workspace/willRenameFiles - (8)' in 2ms.
Result: {
    "documentChanges": []
}

dharrigan14:05:04

the ns stays at (ns foo) with clj-kondo flagging it now as namespace does not match

ericdallo15:05:32

are the project source-paths configured properly?

ericdallo15:05:41

could you print your lsp server info?

ericdallo15:05:24

from your snippet, it seems it's a temp file, not from a real project, right? if so, that's intended

dharrigan15:05:57

a real project requires a deps.edn or project.clj?

dharrigan15:05:02

I moved the file into src and same issue

ericdallo15:05:51

yes, something to bring a valid classpath, please, check https://clojure-lsp.io/troubleshooting/#server-log

borkdude15:05:30

also try rebooting your editor just to be sure

borkdude15:05:39

that it uses the new binary

borkdude15:05:50

I had a similar problem today, and restarting solved the issue for me

dharrigan15:05:31

rebooting editor? You mean just exiting and coming back in again. Done that.

dharrigan15:05:58

I've sent Eric a screen capture of what is happening.

ericdallo15:05:39

@U11EL3P9U could you try calling LSP rename on the namespace to check if the file and references are renamed properly, this works on clojure-lsp for some time, just to make sure source-paths and everything is working as expected

dharrigan15:05:15

Yes, that worked.

ericdallo15:05:12

alright, let me double check creating a sample temp project like you did

ericdallo15:05:48

it seems to work on Emacs, so maybe somthing with vim?

ericdallo15:05:01

although, you showed server sent no data which is weird

ericdallo15:05:17

oh, maybe a graalvm thing facepalm could you test a non graal image?

dharrigan15:05:08

Same problemo. If okay with you, let's park this for now - I have to disappear for a bit. I'll gather some logs and post as an issue, just for reference.

👍 1
dharrigan15:05:28

(I think it would need verification from another vim user too 🙂 )

ericdallo15:05:46

Maybe @UMMMKKADU could help testing this as well?

Noah Bogart15:05:35

i'm also looking into this, lol, so if I find something I'll post here

frozenlock19:05:20

Hello! I'm trying clojure-lsp on a large project and I don't think it's working... but I can't find out why 😕 It looks like references are only found for the file I'm currently in. I deleted the cache file, just in case, but it doesn't appear to have any effect.

frozenlock19:05:35

Any suggestion what I could try next?

frozenlock19:05:55

Definitions are also always "not found"

borkdude19:05:30

@frozenlock after deleting the cache you should restart your workspace in order for clojure-lsp to lint the classpath

borkdude19:05:51

in emacs this can be done through lsp-workspace-restart

borkdude19:05:58

in VSCode this is "reload window" (I think)

frozenlock19:05:06

Yes, I called lsp-restart-workspace but it didn't work. (Still no effect)

borkdude19:05:03

by default clojure-lsp lints your classpath using clojure -Spath when you have a deps.edn. Does that make sense for your project?

borkdude19:05:12

similar for project.clj: lein classpath

frozenlock19:05:42

Ah, probably not. It's a repo with many lein projects

borkdude19:05:24

You can configure the classpath cmd, but maybe @UKFSJSM38 can show you where this is

ericdallo20:05:00

for lein, probably open each lein project as a project would be better

ericdallo20:05:14

unless you have a project.clj on the root that bring correct classpath for all subprojects

frozenlock20:05:43

Alas, it's just hundreds of lein projects

borkdude20:05:33

you could write a script that concatenates all the source paths from the sub projects and uses that as the classpath command

ericdallo20:05:54

well, hundreds of services sounds a lot, you won't be working on those hundreds at the same time probably, I suggest you open only the project you are working

borkdude20:05:47

or add deps.edn files in each sub project and use local/root in your parent project

frozenlock20:05:58

When trying with a single project, llsp always recreates the cache a the repo root, instead of the where the project.clj is located. Am I missing a config somewhere?

ericdallo20:05:48

yep, try lsp-workspace-folders-remove and then lsp and select correct subproject

frozenlock20:05:13

Ah yes it works!

frozenlock20:05:22

Thanks to both of you

👍 2
pez21:05:26

For the record: In Calva it is better to stop and start the clojure-lsp server, instead of full window reload. There are commands for this, and they are also accessible from the clojure-lsp statusbar button. Maybe that is the equivalent to the lsp-workspace-restart in Emacs?

borkdude21:05:36

Maybe that needs a "restart clojure lsp" button

ericdallo21:05:22

Yep, it's equivalent to that