Fork me on GitHub
#lsp
<
2022-04-24
>
shayne.koestler23:04:58

Hello all, I'm working on adding lsp to my emacs config and I was not getting completions for libraries. Then I tried in vscode and got the same result. Should the lsp support be helping me with included libraries? If so, is there some kind of config I'm missing in the .lsp/config.edn? For example, entering (clojure.string/ provides no suggestions. Thanks in advance for any help!

ericdallo23:04:59

keep in mind your code needs to have matching parens like (clojure.string/ )

shayne.koestler23:04:11

Sorry for the confusion, that is what I have been entering as the parens were automatically paired. Thanks

ericdallo23:04:35

right, so we need to debug if clojure-lsp started sucessfully on your buffer

shayne.koestler00:04:41

This bit looks interesting

2022-04-24T17:41:20.488Z  WARN [clojure-lsp.feature.java-interop:258] - [Java] Skipping download JDK source, setting `:java :download-jdk-source?` is disabled.
2022-04-24T17:41:20.489Z  WARN [clojure-lsp.feature.java-interop:272] - [Java] JDK source not found, skipping java analysis.

ericdallo00:04:03

could you share both your emacs config + .lsp/config.edn?

ericdallo00:04:18

BTW from the log clojure-lsp is loading, so probably something else, coyld you share the full server logs?

rayat00:04:31

It doesn't work in vscode either? I had a while where I couldn't get completion to work either, so I deleted every clj-kondo and clojure-lsp related cache file, and all my user-level config for both of those, and also updated my version of calva/kondo/lsp around sort of the same time-ish. I'm not sure which of the above made it eventually work, but now my definitions and completions work better than ever before, and I even get code actions (lightbulb menu in some IDEs) for "require/import this symbol from ... ns"

shayne.koestler00:04:53

At the very end of the log file you can see completion requests I made to a library

shayne.koestler00:04:53

As far as config, I reverted to an out-of-the-box doom setup and I didn't have a .lsp/config.edn yet but I did have .clj-kondo/config.edn with {:lint-as {mount.core/defstate clojure.core/def}}

ericdallo00:04:03

Yeah, server looks ok, alright, try: ā€¢ remove cache file rayat mentioned: .lsp/.cache and restart server and paste logs here, pay attention if no errors when trying to get classpath

ericdallo00:04:09

It's ok not have a config.edn

ericdallo00:04:31

lsp-workspace-restart to restart server

ericdallo00:04:09

BTW from the logs, I think you don't have latest clojure-lsp, I suggest you update just to be sure it's not a fixed bug

shayne.koestler00:04:47

I installed via homebrew, is that what you would recommend or should I do something different?

ericdallo00:04:33

If installed via homebrew tap following https://clojure-lsp.io/installation/ its ok

shayne.koestler00:04:17

2022-04-25T00:21:16.841Z  ERROR [clojure-lsp.classpath:74] - Error while looking up classpath info in /Users/shayne/Sandbox/clojure/sagas Cannot run program "clojure" (in directory "/Users/shayne/Sandbox/clojure/sagas"): error=2, No such file or directory

shayne.koestler00:04:22

I think I know now

ericdallo00:04:05

Yep, emacs not finding clojure

shayne.koestler00:04:23

Clearing the .cache still seems essential

ericdallo00:04:23

Yeah, I plan to fix that for next release, it seems a exception on loading classpath still caches empty analysis

shayne.koestler00:04:48

Thanks so much for the help

šŸ‘ 1
shayne.koestler00:04:01

Just to be clear, is it emacs trying to run that clojure command or the lsp server?

shayne.koestler01:04:15

(clojure.java.shell/sh "echo test")
1. Caused by java.io.IOException
   error=2, No such file or directory 

ericdallo02:04:22

Not sure what that means

shayne.koestler02:04:22

Sorry, I'm trying to run clojure using the same sh function that's being used in clojure-lsp

shayne.koestler02:04:44

clojure-lsp still can start clojure but this works

(clojure.java.shell/sh "clojure" "-version")
in my repl

ericdallo02:04:21

your repl is different that what clojure-lsp is using, clojure-lsp relies on the PATH that emacs is using

ericdallo02:04:46

so you need to fix that on emacs side to clojure-lsp be able to find clojure in the shell spawned from emacs

ericdallo02:04:22

BTW I fixed on clojure-lsp to not cache when classpath scan fails. you can find soon a nightly build on #clojure-lsp-builds meanwhile

shayne.koestler02:04:58

When you say fix that on the emacs side, do you mean adding the directory that contains the clojure bin to the exec-path variable?

ericdallo02:04:33

yeah, usually doom already takes care of that, maybe try lauching doom-emacs from your terminal? I know this happens for some mac users

shayne.koestler02:04:07

So I was setting exec-path but when I start emacs via the terminal the process-environment variable gets my full path

ericdallo02:04:14

I thought doom already uses that

shayne.koestler02:04:51

Either way, I really appreciate your help.

šŸ‘ 1