Fork me on GitHub
#lsp
<
2022-05-17
>
practicalli-johnny13:05:46

[solved] Curious error message from Clojure LSP regarding Leiningen when first adding LSP to a project. Strangely its a deps.edn project, although I added an empty profile.clj file for deploying to Heroku (to identify its a Clojure project). Is there a way to tell clojure-lsp that the project is defined by deps.edn rather than project.clj, perhaps avoiding this error? I am aware that Leiningen will generate the -Xverify:none error as I am using Java 17. Is that actually affecting the classpath clojure-LSP will use? Any useful things I can do to check?

LSP :: Connected to [clojure-lsp:1226824/starting].
LSP :: Classpath lookup failed when running `lein with-profile +dev,+test,+test,+dev classpath`. Some features may not work properly. Error: OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
LSP :: clojure-lsp:1226824 initialized successfully in folders: (/home/practicalli/projects/practicalli/banking-on-clojure-webapp)

practicalli-johnny13:05:35

Ah, it seems I can set up something like this. I'll test to see if this removes that message

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

practicalli-johnny13:05:11

Yes, creating .lsp/config.edn and adding the above in a hash-map no longer generates the Classpath message

ericdallo14:05:01

Even so, clojure-lsp will get both classpaths and merge, what was not working before that?

practicalli-johnny16:05:28

The error suggested the classpath hadn't loaded, but I didn't notice any specific issues. I can test by removing the LSP config I added to see if there is an actual effect other than getting rid of the message, although it sounds like there would not be.

ericdallo16:05:25

yeah, if it was a invalid project.clj file, like missing parens or things that lein wouldn't understand, that's expected

ericdallo16:05:36

since clojure-lsp just run a lein classpath under the hood

practicalli-johnny16:05:58

Yes, it would be an invalid project.clj file, as it not really supposed to be used. Once I write a different deploy script I won't need the project.clj file... 😁

👍 1
emilaasa11:11:59

Can I prevent clojure-lsp from trying to read the project.clj files? In the middle of a migration from lein to Clojure tools now and it's broken 🙂

practicalli-johnny11:11:04

@U6T7M9DBR does the project-specs configuration work for you? Add the following to .lsp/config.edn in the project currently being migrated.

:project-specs [{:project-path "deps.edn"
                  :classpath-cmd ["clojure" "-M:env/dev:env/test" "-Spath"]}]
If there is no way to tell Clojure LSP to ignore the project.clj file then I suggest commenting the :deps section of the project.clj file as a temporary workaround. Remember to keep the project.clj a valid clojure file, otherwise there will be errors.

ericdallo13:11:20

The way to ignore is indeed define a project-spec like @U05254DQM suggested

emilaasa13:11:53

Great! I think the problem might be the way my project is structured. There's a git root, and that folder contains multiple other folders that each have a deps.edn, resulting in something like:

.
├── a
│   ├── deps.edn
│   └── project.clj
└── b
    ├── deps.edn
    └── project.clj

emilaasa13:11:45

And there's c and d and so on as well of course 🥲

ericdallo13:11:41

You could have a root deps.edn file that links to all subprojects, that's how clojure-lsp project itself works

👍 1
practicalli-johnny13:11:42

Ah, it seems like a mono-repo. Perhaps you need an .lsp/config.edn in each project. Or alternatively add the above configuration to a user level Clojure LSP configuration, e.g. $HOME/.config/clojure-lsp/config.edn I guess it depends if there are other leiningen projects to be worked on.

emilaasa13:11:09

root deps edn sounds very much like what we need

emilaasa13:11:23

You guys are so helpful!

emilaasa13:11:53

Looking at clojure-lsp root deps.edn file now

👍 1
marciol18:05:03

Hey, I have been facing a problem with new projects, as they don't show the docs or go-to-definition from external libraries. I have pulled out all dependencies and actually ran the project, but even though it's only working for old projects that were already in my machine. Am I missing something?

ericdallo18:05:07

Probably classpath scan is failing

marciol18:05:33

It's weird because lein classpath returns a ton of paths

ericdallo18:05:46

Also, make sure you have latest clojure-lsp

marciol18:05:18

I'm going to read the troubleshooting, but it's a good tip to ensure it's updated. Thanks @UKFSJSM38 for the initial support gratitude-thank-you

👍 1
Drew Verlee19:05:04

LSP isn't active in my current emacs buffer and i would expect it to be. As an example i try to describe a variable i get this message:

Error running timer: (error "The connected server(s) does not support method textDocument/hover.
To find out what capabilities support your server use 'M-x lsp-describe-session'
and expand the capabilities section")
lsp-describe-session opens a gui tree that doesn't list the current file/buffer.

ericdallo19:05:23

Try lsp probably the project/buffer is ignored

ericdallo19:05:40

Check that with lsp-workspace-folders-remove

Drew Verlee19:05:28

ah, it is in lsp-workspace-folders-remove. How is that different then the "blacklist"?

Drew Verlee19:05:18

i assume i want to remove my folder from lsp-workspace-folders-remove.

ericdallo19:05:47

folders-remoce is to remove a existing project from lsp-mode

ericdallo19:05:05

It's useful to re import the project if imported in the wrong dir

Drew Verlee19:05:05

I understand, it's active now. Thanks Eric!

👍 1