Fork me on GitHub
#lsp
<
2024-04-05
>
andrea.crotti12:04:16

on my Mac some refactorings (like clean-ns) take a very long time, even 30 seconds, I tried to run the profiler but don't see much

147  13%     - funcall-interactively
         139  13%      - lsp-clojure-refactor-menu/lsp-clojure-clean-ns-and-exit
         138  12%       - progn
         138  12%        - hydra--call-interactively-remap-maybe
         138  12%         - funcall-interactively
         138  12%          - lsp-clojure-clean-ns
         138  12%           - lsp-clojure--refactoring-call
         138  12%            - lsp-clojure--execute-command
         138  12%             - lsp-send-execute-command
         138  12%              - lsp-workspace-command-execute
         138  12%               - lsp-request
         117  10%                - accept-process-output
          99   9%                 - timer-event-handler
          99   9%                  - apply
          99   9%                   - auto-revert-buffers
          99   9%                    - apply
          99   9%                     - auto-revert-buffers--buffer-list-filter
          37   3%                      - #<subr auto-revert-buffers>
          32   3%                       + auto-revert--buffer-candidates
           3   0%                       + auto-revert-buffer

andrea.crotti12:04:47

has anyone noticed something similar

ericdallo13:04:32

could you try from the terminal to make sure it's not a editor issue:

clojure-lsp clean-ns
in your project root

andrea.crotti13:04:19

I also noticed that I might be using an old versioin, since the homebrew is much older than the one that emacs downloads automatically

andrea.crotti13:04:48

Executed in 10.48 secs fish external usr time 23.09 secs 48.00 micros 23.09 secs sys time 1.28 secs 770.00 micros 1.27 secs time clojure-lsp clean-ns [ 99%] Project analyzed Checking namespaces... Nothing to clear! ______________________________________________________ Executed in 5.90 secs fish external usr time 18.05 secs 53.00 micros 18.05 secs sys time 0.63 secs 911.00 micros 0.63 secs

andrea.crotti13:04:57

well it does take a while

andrea.crotti13:04:11

even after the first run

ericdallo13:04:13

first please update clojure-lsp following the link I mentioned

andrea.crotti13:04:19

time clojure-lsp clean-ns
[ 99%] Project analyzed            Checking namespaces...
Nothing to clear!

________________________________________________________
Executed in    1.91 secs    fish           external
   usr time    2.39 secs    0.06 millis    2.39 secs
   sys time    0.25 secs    1.01 millis    0.25 secs

andrea.crotti13:04:25

oh yeah better now

ericdallo13:04:59

I wish we could remove that clojure-lsp from the homebrew core, it's outdated and maintainers don't want to remove it.

šŸ˜­ 1
ericdallo13:04:17

all because they don't want to download the native binary, but use the JVM one

andrea.crotti13:04:19

still takes a while actually, but I wonder if it's using the one in .emacs.d

ericdallo13:04:30

it's probably using the one from emacs

ericdallo13:04:38

lsp-uninstall-server

ericdallo13:04:52

and let it use the one that you downloaded

andrea.crotti13:04:10

ah wait, it actually ddoes the thing but

lsp-workspace-command-execute: 'workspace/executeCommand' with 'clean-ns' failed.

(error "Timeout while waiting for response.  Method: workspace/executeCommand")

ericdallo13:04:03

that's weird, make sure it's using the updated one with lsp-clojure-server-info , it should print on messages buffer the server-version

andrea.crotti13:04:51

:server-version "2024.03.31-19.15.11-nightly",

ericdallo13:04:06

looks correct

andrea.crotti13:04:08

but yeah still happening even after I restarted Emacs

ericdallo13:04:30

so it's fast on terminal but slow on emacs?

andrea.crotti13:04:38

yeah looks like

ericdallo13:04:44

try the profile again

andrea.crotti13:04:55

weird that it says it times out but it still does it

ericdallo13:04:56

it's weird tho

armed17:04:09

Actually in case if someone uses mise or asdf I made plugin https://github.com/armed/asdf-clojure-lsp

andrea.crotti09:04:21

ok I still haven't solved this issue, lots of refactoring timeout for some weird reason from Emacs

andrea.crotti09:04:28

but others like rename are just perfectly fine

andrea.crotti09:04:49

actually the rename is just lsp-rename , probably all the ones starting with lsp-clojure- are not actually working

andrea.crotti09:04:40

Checking for Native JSON support: OK
Check emacs supports `read-process-output-max': OK
Check `read-process-output-max' default has been changed from 4k: OK
Byte compiled against Native JSON (recompile lsp-mode if failing when Native JSON available): OK
`gc-cons-threshold' increased?: OK
Using `plist' for deserialized objects? (refer to ): OPTIONAL
Using emacs 28+ with native compilation?: OK

andrea.crotti09:04:44

the doctor also seems happy

andrea.crotti09:04:57

well maybe I should enable plist as well

andrea.crotti09:04:50

Cancelling textDocument/documentHighlight(53746) in hook after-change-functions
Cancelling textDocument/codeAction(53745) in hook after-change-functions
Cancelling textDocument/codeAction(53783) in hook after-change-functions
Cancelling textDocument/codeAction(53807) in hook after-change-functions
Cancelling codeLens/resolve(53806) in hook after-change-functions
Cancelling textDocument/codeAction(53816) in hook after-change-functions
Cancelling codeLens/resolve(53815) in hook after-change-functions
Cancelling textDocument/documentHighlight(53823) in hook after-change-functions
Cancelling textDocument/codeAction(53822) in hook after-change-functions
Cancelling codeLens/resolve(53821) in hook after-change-functions
Cancelling textDocument/documentHighlight(53826) in hook after-change-functions
Cancelling textDocument/codeAction(53825) in hook after-change-functions
Cancelling codeLens/resolve(53832) in hook after-change-functions
Cancelling textDocument/documentHighlight(53839) in hook after-change-functions
Cancelling textDocument/codeLens(53836) in hook after-change-functions
Cancelling textDocument/documentHighlight(53846) in hook after-change-functions
Cancelling textDocument/codeLens(53843) in hook after-change-functions
Cancelling textDocument/documentHighlight(53882) in hook after-change-functions
Cancelling textDocument/codeAction(53881) in hook after-change-functions
Cancelling codeLens/resolve(53972) in hook after-change-functions

andrea.crotti09:04:55

I can see a bunch of these

Alexander Kouznetsov19:04:38

Iā€™m using GitLens by GitKraken VSCode extension and I found that clojure-lsp doesnā€™t interact well with it during rebases. When conflicts appear in the clojure source, Clojure LSP blocks the gitlens UI that shows Accept Current, Accept incoming, etc. conflict resolution links in editor. Stopping Clojure LSP immediately causes this UI to appear and work snappily. With Clojure LSP enabled, it works very slowly. Is it possible to automatically detect unresolved conflicts in clojure files and do not attempt to process them by Clojure LSP?

ericdallo19:04:29

not sure how easy would be, also, not sure it's clojure-lsp fault or your editor's lsp client side

Alexander Kouznetsov19:04:16

I guess youā€™re referring to Calva here?

Alexander Kouznetsov19:04:39

Iā€™m referring to this UI

ericdallo20:04:17

yes, not sure why clojure-lsp would lock or freeze things

pez20:04:38

Iā€™m thinking that Calva could very well start acting up on broken structure. But you say that with clojure-lsp disabled it starts to work again. If I can get a repro I can investigate and see if there is something in the lsp-support from Calva that causes it. Well, I can try at least.

Alexander Kouznetsov20:04:47

I think what is needed is a big clojure repository with many source files and projects. And both extensions. Also it is not completely blocking, it just making it very slow. I believe Clojure LSP is trying to catch up with the new changes applied in a rebase and until itā€™s done, the UI is not refreshing. So Iā€™m using ā€œCalva Clojure LSP: Stop the Clojure LSP serverā€ in such situations to speed things up. Do you know any big open source repo I can try it with?

pez20:04:28

Penpot, http://status.im, metabase are the ones popping to mind.

ericdallo20:04:42

LSP does have a file watch feature which the editor send to clojure-lsp all changed files outside the editor (because of a git rebase for example), then clojure-lsp analyze in batch the files, but that should be as fast or faster than analyzing the whole project when starting, sounds like we would need a good repro to undertand it better

aisamu23:04:53

Perhaps the watcher is being triggered once per operation/commit (vs once per rebase)?

rayat22:04:02

Interesting, we have a fairly massive mixed clj/s (lein monolith-powered) mono repo, the kind of setup where many c-lsp features break down, but gitlens diff etc has not been one of them for me over the past couple years

1