lsp

:clojure-lsp: Clojure implementation of the Language Server Protocol: https://clojure-lsp.io/
Mitch 2020-08-14T13:09:33.081200Z

Is there a way to check that .lsp/config.edn is being read by the server in emacs? Trying to debug some issues with macro-defs

ericdallo 2020-08-14T13:22:42.081300Z

I don't think there is such option 😕 You can try to tail -200f /tmp/lsp.out to see if clojure-lsp is logging something useful for you

borkdude 2020-08-14T13:44:26.081700Z

@mitchell_clojure You can make a grave EDN syntax error to see if something throws ;)

Mitch 2020-08-14T13:51:51.084200Z

good ideas! making a breaking change produces WARN clojure-lsp.parser: Cannot read file:///home/m/projects/.../.lsp/config.edn in the file watch. Unsure if that means that lsp is actually reading it in as my config because I get a similar error when breaking regular source buffers

ericdallo 2020-08-14T13:57:20.085Z

Probably is a syntax error on your config.edn

Mitch 2020-08-14T13:58:37.086300Z

My config.edn is

{"macro-defs"
 {clojure.test.check.clojure-test/defspec [{:element :declaration
                                            :tags    ["unused"]}]}}
However I still get unresolved symbol errors on my usages

ericdallo 2020-08-19T13:51:59.093100Z

Hey @mitchell_clojure, with the latest version of clojure-lsp and lsp-mode, you can now run on emacs lsp-clojure-server-info which will get some information that may help us debug your issue 🙂

Mitch 2020-08-19T13:55:14.093300Z

thank you! I really appreciate you guys working on this great tool. going to give it a go this morning as soon as I get a moment :D

👍 1
Mitch 2020-08-19T20:18:29.093600Z

Looks like the project settings are being read correctly, so this is even more mystifying to me...

{:project-root "file:///tmp/lsp_test",
 :project-settings "{\"macro-defs\" {clojure.test.check.clojure-test/defspec [:declaration]}}\n",
 :client-settings {"dependency-scheme" "jar", "source-paths" #{"src" "test"}, "macro-defs" {},
                   "project-specs" nil, "cljfmt" {:indents {}}}, :port 36967}
Could the empty "macro-defs" in :client-settings be clobbering the project config?

ericdallo 2020-08-19T20:37:30.094200Z

@mitchell_clojure we are using clj-kondo for linting, so you probably will need to add a "clj-kondo" map in you config. For more information check https://github.com/snoe/clojure-lsp#initializationoptions

ericdallo 2020-08-19T20:38:21.094600Z

You probably need something like {"clj-kondo" {:lint-as {clojure.test.check.clojure-test/defspec clojure.core/defn}}}

Mitch 2020-08-19T20:49:36.094800Z

ah, okay, so I have to set both a "macro-def" and a "clj-kondo" setting to define new "declaration" macros. This will surpress the kondo error while also telling lsp that the macro is a declaration. Seems to work fine for me. I thought that using the "unused" tag for the declaration element would surpress kondo as well

ericdallo 2020-08-19T22:57:57.095Z

yeah, this is not the final feature, in the future we intend to use only kondo and remove the macro-def as will be unnecessary 🙂

ericdallo 2020-08-14T14:00:30.086400Z

Looks good to me this configuration, are you trying to restart the server with lsp-workspace-restart ?

Mitch 2020-08-14T14:01:10.086600Z

yes, or I will use lsp-workspace-shutdown and then re enter the project to get it to start up

Mitch 2020-08-14T14:03:57.086800Z

I think that the cause is probably that the config.edn is somehow not being used

ericdallo 2020-08-14T14:09:08.087Z

odd... Could you try moving your config.edn to ~/.lsp/config.edn ?

ericdallo 2020-08-14T14:09:19.087200Z

just to test if clojure-lsp finds it

snoe 2020-08-14T14:12:02.087600Z

Are you getting clj-kondo or lsp as the source of diagnostics?

Mitch 2020-08-14T14:14:26.087800Z

everything being reported as lsp, trying the ~/.lsp/config.edn trick now

Mitch 2020-08-14T14:20:01.088Z

yeah, same problem

ericdallo 2020-08-14T16:51:24.088400Z

@snoe anything more to try on this case?

snoe 2020-08-14T16:53:46.088600Z

not sure, fighting something at work so I won't be able to look. How it's launched and getting the project-root/cwd that lsp is using to find the config is probably key.

snoe 2020-08-14T16:54:01.088800Z

like maybe it's launching from /usr/bin or something weird

ericdallo 2020-08-14T16:57:15.089Z

I'll try to later add a debug log when loaded the config, this may help for issue like that

👍 1
snoe 2020-08-14T17:02:16.089300Z

One thing I've been meaning to look at is a command or something in the protocol where you can send back a message. I'd like to be able to get the environment info like this, the config, the repl port etc back in the client

ericdallo 2020-08-14T17:08:03.089500Z

hum, it really seems a good idea, I can implmenet that under executeCommand from lsp protocol, and then add a command on lsp-mode for that , like lsp-clojure-server-info

snoe 2020-08-14T17:23:50.089700Z

yup, unless maybe lsp has something specific for this

Mitch 2020-08-14T17:42:39.090200Z

I'm going to try to narrow it down after work so I will let you guys know if I figure out the root cause. Maybe something to do with some hidden spacemacs configuration

👍 1