Fork me on GitHub
#lsp
<
2021-10-21
>
pez09:10:09

I didn’t know what an amazingly interactive experience it is to hack on clojure-lsp. Did you? I have updated the dev docs to reflect this: https://github.com/clojure-lsp/clojure-lsp/blob/master/docs/development.md Demo here: https://www.youtube.com/watch?v=4UvT0yqBDw8

💜 1
🎉 2
dharrigan09:10:14

In the latest version, I'm getting this error out in my editor Classpath lookup failed when running lein classpath`. Some features may not work correctly.` This is a bit worrying, since in this project, there is both a deps.edn and a project.clj and I think (by looking at crawler.clj) it's mapping through each of the default project specs, to build up a classpath (so it should be okay). However, the error message is off putting. Am I interpreting this correctly?

Asko Nōmm11:10:48

When you run lein classpath yourself does it return any errors? I’ve encountered an error message like this myself, and it’s usually been my fault.

dharrigan11:10:27

Actually, yes, it does return an error, but here's the pinch, it's not a catastrophic error, since I'm using clojure deps to fire up the repl, not lein

dharrigan11:10:23

Thus, I'm not concerned that lein is returning an error, in fact, I would say this is slowing down lsp from starting up, for it maps through all the default project specs to gather up the classpath

dharrigan11:10:19

I think I will have to tell lsp that I only want it to run deps -Spath

dharrigan12:10:26

Yeah, I added

dharrigan12:10:29

:project-specs [{:project-path "deps.edn"
                  :classpath-cmd ["clojure" "-A:dev:test" "-Spath"]}]

dharrigan12:10:52

to my $HOME/.lsp/config.edn and all is fine

ericdallo12:10:21

Be aware that this will make clojure-lsp always ignore lein for every project you run since you added to your home

ericdallo12:10:57

Also, eve clojure-lsp saying classpath lookup failed for lein, it will safely use the deps.edn one, so you can just ignore if for some reason the lein error makes sense

dharrigan13:10:17

it was just a new error that didn't happen before

dharrigan13:10:37

without a comforting message that it worked with gather the classpath from deps

ericdallo13:10:24

We have this message error for some time now, and since the error happens with only running lein classpath, it'srelated with your project indeed and not clojure-lsp

ericdallo13:10:36

you just need to understand why it didn't happen before

dharrigan13:10:50

Strange. I know why it's happening (can't resolve a JAR)

dharrigan13:10:16

it can't resolve the JAR if our VPN is down

dharrigan13:10:25

and that's not the first time it's been down..

ericdallo13:10:58

we have this all the time at nubank 😅 lein classpath fail if we don't have aws creds setup since we have our maven repository at s3

ericdallo13:10:34

so it's pretty common to see folks complaining there that clojure-lsp is not working because their forgot to setup aws creds and lein classpath fails

ericdallo13:10:54

that's why I added the command clojure-lsp runs on the message

dharrigan13:10:55

yeah, we have s3 too 🙂

dharrigan13:10:32

I guess it's fine now, I know how to handle the issue if it arises (yup, we're migrating to deps from lein...but having a transition period)

mpenet15:10:17

seems that autocomplete on code from my own project doesnt' work anymore, not sure what changed

mpenet15:10:40

I get clojure.core and current buffer completions, but the rest nope

ericdallo15:10:30

probably related with wrong source-paths configuration

mpenet15:10:15

not sure, once the symbol is complete lsp shows the signature doc for instance

mpenet15:10:24

ex with clojure.string/includes?

mpenet15:10:40

no completion on it but it does show the signature when in (clojure.string/includes?|)

mpenet15:10:51

I have to run, bbl

ericdallo15:10:17

The signature has nothing related with the completion, I suspect your source-paths are wrong indeed

mpenet15:10:08

doubt it, my deps.edn has only src

mpenet15:10:30

:paths ["src"]

mpenet15:10:18

lsp-server advertises :source-paths ["src" "test"],

mpenet15:10:53

anyway, I ll check this tomorrow, kids time

ericdallo16:10:24

odd, you can try rm .lsp/.cache and reload your editor

mpenet07:10:20

it seems it works if the thing is fully qualified ex: if I type (clojure.string/incl|) it will autocomplete, but my require alias gets no completion

mpenet07:10:21

fully qualified names on a defn in my own project fails tho (in another ns)

mpenet07:10:03

clojure-lsp --version clojure-lsp 2021.10.20-13.04.11 clj-kondo 2021.10.19

mpenet07:10:04

did rm ./.lsp and ./.clj-kondo

mpenet08:10:57

if I type (s/|) autocomplete pops saying s is a Property (it's an alias to clojure spec in that case), but nothing gets completed on it

mpenet08:10:16

and my emacs config so you have a complete picture : https://github.com/mpenet/emax/blob/master/init.el#L486-L505

mpenet08:10:45

I keep trying messing with various things but I can't make it work

mpenet08:10:17

another clue: if clojure.spec.alpha is required it breaks all completion on (clojure.spec.alpha/|)

mpenet08:10:24

if not required completion on it works

mpenet08:10:15

same with my own code, or an exernal lib on the classpath, once required completion on it fails

mpenet09:10:11

well the nrepl server fails to start, there's that

mpenet09:10:36

added nrepl+cider-nrepl to classpath just to test, the error goes away but completion behavior is still the same

mpenet09:10:46

still broken with clojure-lsp mater

mpenet10:10:15

and now it works, not sure what fixed it. I rm'ed my .emacs.d/straight/* files and copied your .lsp/config.edn. About the straight part, I did do a straight-pull-all before all these tests, so I am not sure what's different

mpenet10:10:02

same pinned version of all repositories in straight too, a real mistery. In any case, sorry about the noise 🙂 at least I got to learn how to work-on /debug clojure-lsp

mpenet11:10:29

without having a repl running everything is fine

mpenet11:10:41

when cider jacked in, completions go away

mpenet11:10:11

describe-var on lsp-enable-completion-at-point -> t

mpenet11:10:25

(add-hook 'cider-mode-hook (lambda () (remove-hook 'completion-at-point-functions #'cider-complete-at-point))) ; use lsp

mpenet11:10:41

from your conf heh

ericdallo12:10:49

Yeah, cider completion mess up with lap one unless you add that :/

mpenet13:10:05

well for some reason with these config changes I lost clojure.core/* completions

mpenet13:10:45

only in the current ns I am working on, maybe something fishy that lsp doesn't like on it

ericdallo13:10:14

try not using cider on the proejct until we understand what is the issue

mpenet13:10:10

I am not right now

mpenet13:10:36

it's weird, completion on core works at the end of the ns (after a bunch of code), not right after the ns declaration

mpenet13:10:42

so same buffer

mpenet13:10:05

it completes all the other stuff tho (clojure.specs & co)

mpenet13:10:22

killed the session, re-opened and now it works

ericdallo14:10:48

odd, if you manage to reproduce again feel free to open an issue with a sample repro where I can try

dmegas18:10:08

Coming back to my message from yesterday and the issues I face with finding a var’s references, I am able to reproduce the behaviour even in clojure-lsp’s own https://github.com/clojure-lsp/clojure-lsp: • I start with opening just the clojure-lsp.handlers namespace and for call-hierarchy-outgoing I get 0 references from the lens and the lsp-find-references command does not return any results https://clojurians.slack.com/files/U9V9M9MFZ/F02JMGHSJF5/image.png • When I then open the clojure-lsp.server namespace (which has a reference to clojure-lsp.handlers/call-hierarchy-outgoing) I can view the reference and the lens gets updated https://files.slack.com/files-pri/T03RZGPFR-F02J6RQJ7FH/image.png

ericdallo18:10:08

@U9V9M9MFZ this sounds like wrong workspace configured in your lsp-mode

ericdallo18:10:40

could you try lsp-workspace-folders-remove , and remove any wrong folder, like your home and the clojure-lsp project

ericdallo18:10:56

and then M-x lsp and select the correct project root for clojure-lsp

dmegas18:10:45

Yes, that did the trick - thank you very much 🙏 ! Indeed my home folder had to be removed along with some clojure folders - don’t know how they ended up there, I have never called lsp directly, I have it starting when I visit a clojure namespace. Anyways, thanks again!

ericdallo18:10:28

good :) that's a common issue on lsp-mode

dmegas18:10:11

ah I see, noted!