Fork me on GitHub
#lsp
<
2021-09-16
>
mpenet08:09:41

gave another try to clojure-lsp today after a long hiatus, and wow, I am impressed, hats off to all the people involved, it's really a smooth ride now

🎉 6
gratitude 2
mpenet08:09:03

(I am using it in parallel with cider)

mpenet09:09:23

can you share your conf? I am curious to see the way you set it up

mpenet09:09:53

I disabled most of the UI stuff (headers & other noise), but I am sure I missed some cool stuff

borkdude09:09:50

@mpenet I've done the same, I don't like the noise, but I did enable lens-mode which is quite convenient in that it shows the amount of references. I'll look up my config.

mpenet09:09:53

yeah, lens-mode makes everything quite slow

borkdude09:09:31

I haven't noticed that. This is my config: https://github.com/borkdude/prelude/blob/master/personal/init.el#L356-L409 Note, I don't optimize my emacs config for share-ability ;)

borkdude09:09:59

I run my own version of clj-kondo because I develop that project, so I disabled diagnostics in lsp which bundles clj-kondo

borkdude09:09:07

which is probably not what you want to do

borkdude09:09:53

I made a function to combine find-definition from lsp + CIDER as you can see

borkdude09:09:13

and then hooked that up to M-.

borkdude09:09:59

probably a left-over from a debugging sessions when I had some performance issues

djm11:09:20

When CIDER 1.2 is released, the built-in xref-find-definitions will be able to use both cider and lsp as backends, similarly to your find-definition

kommen10:09:17

I’m running into problems where clojure-lsp doesn’t start up in my projects any more after upgrading to the latest version. anybody has similar problesm?

kommen10:09:51

Upgraded from 2021.09.04-17.11.44 to 2021.09.13-22.25.35

kommen10:09:48

the server log shows this:

kommen10:09:51

2021-09-16T09:57:38.614Z Totaranui.local INFO [clojure-lsp.kondo:137] - Analyzing 3/8 batch paths with clj-kondo...
2021-09-16T09:57:56.273Z Totaranui.local ERROR [clojure-lsp.server:?] - 
                                 com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine            PosixJavaThreads.java:  192
                                             com.oracle.svm.core.thread.JavaThreads.threadStartRoutine                 JavaThreads.java:  567
                                                                                  java.lang.Thread.run                      Thread.java:  829
                                                    java.util.concurrent.ThreadPoolExecutor$Worker.run          ThreadPoolExecutor.java:  628
                                                     java.util.concurrent.ThreadPoolExecutor.runWorker          ThreadPoolExecutor.java: 1128
                                                                   java.util.concurrent.FutureTask.run                  FutureTask.java:  264
                                                   java.util.concurrent.Executors$RunnableAdapter.call                   Executors.java:  515
                                         org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run  ConcurrentMessageProcessor.java:  113
                                           org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen       StreamMessageProducer.java:   94
                                    org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage       StreamMessageProducer.java:  194
                                                      org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume              RemoteEndpoint.java:  190
                                                org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest              RemoteEndpoint.java:  261
                                            org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request             GenericEndpoint.java:  120
                                      org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0             GenericEndpoint.java:   65
                                                                                                   ...                                       
clojure_lsp.server.proxy$clojure_lsp.ClojureExtensions$ExtraMethods$LanguageServer$4129860f.initialize                                       
                                                                              clojure-lsp.server/fn/fn                       server.clj:  301
                                                                       clojure-lsp.handlers/initialize                     handlers.clj:   49
                                                                clojure-lsp.crawler/initialize-project                      crawler.clj:  195
                                                                clojure-lsp.crawler/analyze-classpath!                      crawler.clj:  146
                                                       clojure-lsp.crawler/analyze-external-classpath!                      crawler.clj:  101
                                                           clojure-lsp.kondo/run-kondo-on-paths-batch!                        kondo.clj:  139
                                                                                   clojure.core/reduce                         core.clj: 6826
                                                                           clojure.core.protocols/fn/G                    protocols.clj:   13
                                                                             clojure.core.protocols/fn                    protocols.clj:   75
                                                                     clojure.core.protocols/seq-reduce                    protocols.clj:   27
                                                                           clojure.core.protocols/fn/G                    protocols.clj:   19
                                                                             clojure.core.protocols/fn                    protocols.clj:  169
                                                                                     clojure.core/next                         core.clj:   64
                                                                                                   ...                                       
                                                                      clojure.core/map-indexed/mapi/fn                         core.clj: 7312
                                                        clojure-lsp.kondo/run-kondo-on-paths-batch!/fn                        kondo.clj:  138
                                                                 clojure-lsp.kondo/run-kondo-on-paths!                        kondo.clj:  120
                                                                                   clj-kondo.core/run!                         core.clj:  189
                                                                                  clojure.core/sort-by                         core.clj: 3107 (repeats 2 times)
                                                                                     clojure.core/sort                         core.clj: 3101
                                                                                 clojure.core/to-array                         core.clj:  346
                                                                                                   ...                                       
                                                           clj-kondo.impl.core/filter-findings/iter/fn                         core.clj:  491
                                                        clj-kondo.impl.core/filter-findings/iter/fn/fn                         core.clj:  504
                                                                                  clojure.core/comp/fn                         core.clj: 2574
                                                                                     clojure.core/some                         core.clj: 2705
                                                     clj-kondo.impl.core/filter-findings/iter/fn/fn/fn                         core.clj:  505
                                                                                  clojure.core/re-find                         core.clj: 4887
                                                                               clojure.core/re-matcher                         core.clj: 4845
                                                                       java.util.regex.Pattern.matcher                     Pattern.java: 1133
                                                                        java.util.regex.Matcher.<init>                     Matcher.java:  253
                                                                         java.util.regex.Matcher.reset                     Matcher.java:  416
                                                                 java.util.regex.Matcher.getTextLength                     Matcher.java: 1770
java.lang.NullPointerException: 

2021-09-16T09:57:56.278Z Totaranui.local DEBUG [clojure-lsp.server:?] - :initialize 72979ms

borkdude10:09:52

Could be an issue with your config.

borkdude10:09:58

perhaps share your config?

borkdude10:09:04

wrt/ to that

kommen10:09:27

:output {:exclude-files ["unrepl-blob"
                          "scratch/templates/styleguide"
                          "public/js"
                          "compiled"]}

kommen10:09:46

maybe one of those doesn’t exist any more

kommen10:09:52

checking…

borkdude10:09:02

can you reproduce the issue when using clj-kondo on the command line and linting your project?

borkdude10:09:17

it could be that lsp inserts a finding without a filename

borkdude10:09:29

perhaps for the public var linter

borkdude10:09:16

or some other bug

borkdude10:09:25

but I think the filename may be null or so

borkdude10:09:45

and you would likely see this when linting your project (and removing this config temporarily)

kommen10:09:37

so lsp starts sucessfully when removing the 4 entries in the :exclude-files vector

borkdude10:09:24

I expected that

borkdude10:09:10

so can you lint on the command line

borkdude10:09:15

perhaps using clojure-lsp

borkdude10:09:29

and then watch the output to see if it has any missing filenames

kommen10:09:19

this didn’t crash

kommen10:09:22

clj-kondo --lint "$(clojure -Spath)"  --parallel --copy-configs 

kommen10:09:43

but also is a different clj-kondo version than what clojure-lsp uses

borkdude10:09:46

it didn't crash with the config?

borkdude10:09:00

can you download the clojure-lsp binary

borkdude10:09:03

and do a similar thing

borkdude10:09:09

you can use it on the command line

kommen10:09:49

you mean runngin clojure-lsp diagnostics in the project?

kommen11:09:59

also works with the config

borkdude11:09:31

and is this the same clojure-lsp version you are using in your editor?

kommen11:09:35

now the clojure-lsp server also starts in the editor again

kommen11:09:55

yep, problem seems to be gone. sorry, no idea what I did here to either break or then fix it

borkdude11:09:43

hmm, these are the nastiest bugs: the ones that aren't reproducible ;)

borkdude11:09:48

let's hope it won't occur again

kommen11:09:20

at least I now know to check with clojure-lsp diagnostics first

kommen11:09:42

thank you Michiel!

👍 2
ericdallo12:09:26

That's odd, if you face the issue again let us know @U45J3R52L, thanks for the debug help @U04V15CAJ

martinklepsch11:09:02

Does clojure-lsp support something like moving a function to a new namespace?

ericdallo12:09:27

Not yet, but I already thought about a code action to do that, please open an issue, it sounds a good idea indeed

👍 2
mpenet11:09:20

I am used to https://github.com/wolray/symbol-overlay for highlighting, it's similar to lsp-symbol-highlighting but it also allows to make some highlight persistent and have multiple of them on a buffer (with different color per highlight), it's quite handy, is there anything similar possible with lsp? I know about lsp-symbol-highlighting but it does just the first part, "idle" highlighting

mpenet11:09:39

it's super handy when you pair for instance, or for live reviews

borkdude11:09:26

Probably @ericdallo knows more about this. Perhaps someone in the emacs lsp-mode channel on Discord knows as well.

borkdude11:09:50

But Eric should be here within an hour or so usually ;)

mpenet11:09:10

I am not in a hurry 🙂 . lsp-symbol-highlighing already uses overlays (good!), so that's probably somewhat easy to add I supose

ericdallo12:09:35

@mpenet unfortunately the LSP protocol for the document highlight doesn't support that kind of feature :/ and adding a custom wrapper around that would need to make bug changes on both lsp-mode, clojure-lsp and other editors, although there is lsp-iedit-highlights that I use all the time which makes the highlights persisted, it will show only one color but it's more than the default behavior

mpenet12:09:30

I think I might be able to pair both modes

mpenet12:09:05

just use the persistence feature of symbol-overlay and let lsp do the idle highlighting (it's a bit smarter than symbol overlay, since it can "resolve" vars)

mpenet12:09:30

I have to see if symbol olverlay idle highlighting can be disabled

ericdallo12:09:01

That probably could be improved on lsp-mode to integrate with the document-highlight as we did for iedit, you may want to open an issue on lsp-mode sharing this idea

mpenet12:09:09

will do, thanks

mpenet12:09:17

yeah, just not enabling symbol-overlay-mode and using symbol-overlay-put & co separately works like a charm

mpenet12:09:31

I can rely on lsp for the rest

👍 2
djm13:09:18

smartscan is another similar package 😁

JonR16:09:05

Does anyone know a way to see a list of the references displayed by lsp-lens? I'm hoping there is something like the lsp-ui that lists fns in an ns but listing the references and a quick way to jump to them

ericdallo16:09:55

isn't lsp-ui-peek-find-references enought? or simpler, lsp-find-references

ericdallo16:09:36

otherwise there is lsp-treemacs-symbols but it show all vars and not references of the namespace

JonR16:09:42

Yes sir! Those are exactly what i was looking for

👍 2
JonR16:09:53

Trying to get lsp-treemacs installed but still new to doom and having issues

ericdallo16:09:09

you just need to enable a flag to have treemacs installed

JonR16:09:10

I saw in your dotfiles it looked like you load it from a local version, is that correct?

JonR16:09:18

So I have treemacs and am using it

ericdallo16:09:53

that local version of mine is just for development 😅

ericdallo16:09:59

that's why it's commented

JonR20:09:11

So @ericdallo I added the (treemacs +lsp) and things start up cleanly but not treemacs... When I add this

(use-package! lsp-treemacs
  :config
  (setq lsp-treemacs-error-list-current-project-only t))
in my config.el I get an error that the treemacs file/dir doesn't exist. Any tips?

ericdallo20:09:47

it seems an outdated doom config, are you running doom sync ?

JonR20:09:15

I did a couple days ago I think but will do ago now

JonR20:09:20

Oh, man. Do I need to doom sync whenever I add to init.el?

ericdallo20:09:23

everytime you change your init.el/packages.el you need to run doom sync

JonR20:09:33

:man-facepalming:

JonR20:09:45

Sorry for the noob questions, new to doom and lsp 🙂

JonR20:09:29

Last question today, are most people running lsp-clojure along side cider? I am currently doing that for repl support but wondering if I should be doing something else.

JonR20:09:34

And thanks @ericdallo, lsp-treemacs is working and awesome!

ericdallo20:09:00

no, use both it's actually a good choice IMO

👍 2
ericdallo20:09:32

check this, it should help with some questions and doom conflicts: https://emacs-lsp.github.io/lsp-mode/tutorials/clojure-guide/

ericdallo20:09:38

there are some Doom emacs user sections

JonR20:09:25

sweet, thanks again!