Fork me on GitHub
#lsp
<
2021-06-25
>
borkdude12:06:53

The latest clojure-lsp has become more instable for me than the previous one. E.g. when I do clojure-sort-ns in emacs (powered not by LSP), lsp locks up emacs and CPU spikes to 100%

borkdude12:06:29

Unfortunately I don't have time for a repro now

ericdallo12:06:34

Hum, odd, could you try disabling LSP formatting ?

ericdallo12:06:51

lsp-enable-fornatting I think

borkdude12:06:32

(setq gc-cons-threshold (* 100 1024 1024)
      read-process-output-max (* 1024 1024)
      treemacs-space-between-root-nodes nil
      lsp-headerline-breadcrumb-enable nil
      company-idle-delay 0.5
      lsp-idle-delay 0.5
      company-minimum-prefix-length 1
      ;; lsp-lens-enable t
      lsp-enable-file-watchers nil
      lsp-file-watch-threshold 10000
      lsp-signature-auto-activate nil
      lsp-clojure-custom-server-command '("/Users/borkdude/Dropbox/bin/clojure-lsp")
      lsp-diagnostics-provider :none
      lsp-enable-indentation nil ;; uncomment to use cider indentation instead of lsp
      ;; lsp-enable-completion-at-point nil ;; uncomment to use cider completion instead of lsp

      lsp-completion-provider :capf)

borkdude12:06:45

so add lsp-enable-formatting nil ?

borkdude12:06:34

lsp-enable-on-type-formatting nil

ericdallo13:06:12

Yes, you can add both to test if performance is changed

borkdude13:06:05

Not related to lsp, it also happens without lsp. Sorry for the false alarm! (tl;dr: it was clojure-sort-ns itself stuck in a loop!)

👍 2
borkdude13:06:39

It seems I got clojure-mode stuck in a loop

ericdallo13:06:14

:thinking_face: maybe a profiler can help understand which function

borkdude13:06:42

clojure-sort-ns it was

ericdallo13:06:48

Hum, maybe #emacs can help on that, meanwhile you can try lsp-organize-imports

ericdallo13:06:00

Any reason for not using the LSP way?

borkdude13:06:08

Inertia

😄 2
borkdude13:06:58

thanks for organize-imports, will try that next time!

👍 2
borkdude13:06:14

oh it will also sort referred vars? niiice

borkdude13:06:29

dude, you really have to expose this stuff as a library

borkdude13:06:15

I mean, there's no reason why you couldn't have this stuff as a git pre-commit hook or so right

👍 2
ericdallo13:06:16

Yeah, I was thinking in taking that issue and making it available via REPL

borkdude13:06:57

I think lib is nice. You could also expose it via the command line (e.g. using sci) via scripts, or as a babashka pod

ericdallo13:06:13

Hum, good idea

borkdude13:06:21

So lib first (designing API is the hardest problem probably?) and then you can build the rest on top of it: scripting, pod

ericdallo13:06:03

Yes, I think API and how to manage the classpath is the probably ATM

ericdallo13:06:16

Probably, it'd need to passa the project root or something

ericdallo13:06:47

To clojure-lsp scan the project with kondo

borkdude13:06:10

but perhaps that can also just leverage the existing .lsp config

ericdallo13:06:45

Yes, IMO it should use the same config as it uses today

ericdallo13:06:53

Looks nice, I'll take a look on it later, thanks for the tip

borkdude13:06:03

:thumbsup: :D

borkdude13:06:35

I think I could also deprecate carve possibly, since the logic in clojure-lsp can do much more

ericdallo13:06:26

Yes, ATM the clean-ns sort and remove unused require/refers/imports

borkdude13:06:53

lsp-organize-imports does this right? it works really neat!

ericdallo13:06:10

yes, it calls the clean-ns code-action under the hood

ericdallo18:06:08

You can pass --project-root and --namespaces It works better than I thought 😄

ericdallo18:06:58

And I accidentally linted my entire project 😆

ericdallo18:06:43

I liked the API as well, using tools.cli

ericdallo18:06:36

Need to work in some corner cases and integration tests for that (babashka) then I can announce as experimental 🙂

borkdude18:06:47

@ericdallo Can you configure what it will "fix"?

borkdude18:06:05

And does it also remove unused vars... and unused locals... that can be a bit dangerous I guess :)

vemv18:06:23

Nice! Looking forward to that API :)

🚀 3
ericdallo18:06:02

ATM no, but it'd be easy to introduce opt-outs. it cleans only the ns form, maybe clean-ns as the api would be more clear

borkdude18:06:34

Perhaps you could configure this in .lsp/config.edn what to "automatically" fix on a CLI invocation

borkdude18:06:39

similar to what carve does

borkdude18:06:50

also with ignores, etc

ericdallo18:06:00

yes, I made the API consider the .lsp/config.edn as well, so it'd be easy to introduce customizations

borkdude18:06:31

e.g. with carve you can specify which vars to ignore or define "API" namespaces so unused vars are left alone

borkdude18:06:05

but I guess that can be just the config of the unused-var linter in lsp in general

borkdude18:06:09

no warning = no action

ericdallo18:06:44

yes, I need to test, but if you configure your linter that way it may work as expected 🙂

ericdallo18:06:58

no warning = no action (only sort, that could be disabled in a future setting as well)

borkdude18:06:40

yeah, cool.

metal 3
borkdude13:06:05

Not related to lsp, it also happens without lsp. Sorry for the false alarm! (tl;dr: it was clojure-sort-ns itself stuck in a loop!)

👍 2
ericdallo20:06:07

That's awesome!

🎉 13