lsp

:clojure-lsp: Clojure implementation of the Language Server Protocol: https://clojure-lsp.io/
borkdude 2021-06-25T12:55:53.202300Z

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%

borkdude 2021-06-25T12:56:29.202600Z

Unfortunately I don't have time for a repro now

ericdallo 2021-06-26T18:20:56.212800Z

Spoiler:

ericdallo 2021-06-26T18:21:08.213200Z

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

ericdallo 2021-06-26T18:21:58.213400Z

And I accidentally linted my entire project 😆

borkdude 2021-06-26T18:22:12.213800Z

:-D

ericdallo 2021-06-26T18:22:43.214Z

I liked the API as well, using tools.cli

borkdude 2021-06-26T18:22:50.214200Z

:thumbsup:

ericdallo 2021-06-26T18:23:36.214400Z

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

ericdallo 2021-06-26T18:23:49.214600Z

c/c @vemv

borkdude 2021-06-26T18:26:47.214800Z

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

borkdude 2021-06-26T18:27:05.215Z

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

vemv 2021-06-26T18:27:23.215200Z

Nice! Looking forward to that API :)

🚀 1
ericdallo 2021-06-26T18:28:02.215400Z

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

borkdude 2021-06-26T18:28:34.215700Z

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

borkdude 2021-06-26T18:28:39.215900Z

similar to what carve does

borkdude 2021-06-26T18:28:50.216100Z

also with ignores, etc

ericdallo 2021-06-26T18:29:00.216300Z

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

borkdude 2021-06-26T18:29:31.216500Z

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

borkdude 2021-06-26T18:30:05.216700Z

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

borkdude 2021-06-26T18:30:09.216900Z

no warning = no action

ericdallo 2021-06-26T18:31:44.217100Z

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

ericdallo 2021-06-26T18:31:58.217300Z

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

borkdude 2021-06-26T18:32:40.218100Z

yeah, cool.

🤘 1
ericdallo 2021-06-25T12:57:34.202700Z

Hum, odd, could you try disabling LSP formatting ?

ericdallo 2021-06-25T12:57:51.202900Z

lsp-enable-fornatting I think

borkdude 2021-06-25T12:58:32.203100Z

(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)

borkdude 2021-06-25T12:58:45.203300Z

so add lsp-enable-formatting nil ?

borkdude 2021-06-25T12:59:34.203500Z

lsp-enable-on-type-formatting nil

ericdallo 2021-06-25T13:00:12.203700Z

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

borkdude 2021-06-25T13:10:39.204300Z

It seems I got clojure-mode stuck in a loop

ericdallo 2021-06-25T13:11:14.204500Z

:thinking_face: maybe a profiler can help understand which function

borkdude 2021-06-25T13:11:42.204700Z

clojure-sort-ns it was

ericdallo 2021-06-25T13:12:48.204900Z

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

ericdallo 2021-06-25T13:13:00.205100Z

Any reason for not using the LSP way?

borkdude 2021-06-25T13:13:08.205300Z

Inertia

😄 1
borkdude 2021-06-25T13:13:58.205600Z

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

👍 1
borkdude 2021-06-25T13:14:14.205900Z

oh it will also sort referred vars? niiice

borkdude 2021-06-25T13:14:29.206100Z

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

ericdallo 2021-06-25T13:14:50.206300Z

Yes hahah

borkdude 2021-06-25T13:15:15.206500Z

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

👍 1
ericdallo 2021-06-25T13:15:16.206700Z

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

ericdallo 2021-06-25T13:15:20.206900Z

Or lib

borkdude 2021-06-25T13:15:57.207200Z

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

ericdallo 2021-06-25T13:16:13.207600Z

Hum, good idea

borkdude 2021-06-25T13:19:21.207900Z

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

ericdallo 2021-06-25T13:20:03.208100Z

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

ericdallo 2021-06-25T13:20:16.208300Z

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

ericdallo 2021-06-25T13:20:47.208500Z

To clojure-lsp scan the project with kondo

borkdude 2021-06-25T13:20:56.208700Z

yeah

borkdude 2021-06-25T13:21:10.208900Z

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

ericdallo 2021-06-25T13:21:45.209100Z

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

ericdallo 2021-06-25T13:21:53.209300Z

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

borkdude 2021-06-25T13:22:03.209500Z

:thumbsup: :D

borkdude 2021-06-25T13:37:35.209700Z

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

borkdude 2021-06-25T13:37:52.209900Z

over time

ericdallo 2021-06-25T13:38:26.210100Z

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

borkdude 2021-06-25T13:40:53.210300Z

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

ericdallo 2021-06-25T13:41:10.210500Z

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

borkdude 2021-06-25T15:54:02.211500Z

TIL! https://twitter.com/borkdude/status/1408452763915374592 Thanks @ericdallo

🎉 4
ericdallo 2021-06-25T20:33:07.212100Z

That's awesome!

🎉 5