lsp

:clojure-lsp: Clojure implementation of the Language Server Protocol: https://clojure-lsp.io/
Timofey Sitnikov 2021-06-03T11:17:18.114700Z

Good morning all. I am trying to build my clojure environment. Does it make sense to use Iced with Clojure LSP? Or will they trip on each other?

nbardiuk 2021-06-03T11:28:37.114900Z

They have some overlapping functionality but should not cause conflicts. Just be careful with keys mapping, iced maps <C-]> == and K by default

Ben 2021-06-03T11:42:37.119100Z

Hello folks, I am using VSCode with Calva, and references across namespaces do not work (i.e., they are not found). Our setup is a monorepo with several subprojects, two of which have lsp/config.edn at their root. I found that when I create another lsp/config.edn at the repo root, listing the union of the paths from the subprojects under "source-paths", all of a sudden, references work perfectly. I have not been able to understand why that should be so though. Shouldn’t lsp find all these paths regardless of whether I place them in the config file at the project root, or in a nested folder?

Ben 2021-06-03T12:21:56.119200Z

The issue does indeed seem to be caused by the fact that the source paths listed in the config files for subprojects are not taken into account, because in the absence of a root level config, I see in the logs:

Ben 2021-06-03T12:22:30.119600Z

This is so fast that it seems clear no paths were actually found that had to be analyzed …

ericdallo 2021-06-03T15:09:03.120Z

By default clojure-lsp check for the default source paths (src and test) from project root, if you have a mono-repo you probably need to configure a different :source-path

ericdallo 2021-06-03T15:09:26.120200Z

Also clojure-lsp checks for deps.edn/project.clj on the project root

Ben 2021-06-03T15:21:44.120400Z

Thank you! I think I am getting closer. 🙂 One more question: in the documentation, it says that clojure-lsp will go upwards from the project root looking for config files. I am assuming once a config is found, this search will stop, correct? So if • my directory structure is dir1/dir2/dir3 • my project root is dir3 • I have config.edn for lsp both in dir1 and dir3 … then the configuration in dir3 will be taken into account, whereas the one in dir1 won’t be. Is that right?

ericdallo 2021-06-03T16:09:15.120600Z

From https://github.com/clojure-lsp/clojure-lsp/blob/master/src/clojure_lsp/config.clj#L87-L90 if you have the project root as /tmp/dir1/dir2/dir3 and config on dir1(`{:a 1}`) and dir3(`{:b 2}`), it will deep merge both:

(resolve-project-configs "file:///tmp/dir1/dir2/dir3" (io/file "/home/any"))
=> [{:a 1} {:b 2}]

👍 1
ericdallo 2021-06-03T16:10:03.120900Z

basically, clojure-lsp wil recur until / searching for .lsp/config.edn

seancorfield 2021-06-03T16:10:25.121100Z

@ben477 We have a monorepo at work and use the CLI / deps.edn and after trying various configurations, we’ve ended up with a “primary” deps.edn at the top of the repo — and run an “everything” REPL from there and that’s also where LSP’s root is so it “sees” all code (all 113K lines in 40+ subprojects). Read the two “deps.edn and monorepos” posts here for more details: https://corfield.org/archives/ We’re currently migrating things piecemeal to the Polylith architecture, which takes a similar approach with a workspace-level deps.edn and a :dev alias for “everything” for the REPL (and LSP etc).

👍 2
seancorfield 2021-06-03T16:11:12.121500Z

(we used to have a more subproject-based approach but it just wasn’t amenable to working with tooling across the whole repo)

ericdallo 2021-06-03T16:11:27.121700Z

you can test what is the config being retrieved with server-info command (not sure how to get this on Calva, do you know if it's possible @brandon.ringe?)

Ben 2021-06-03T17:46:20.122100Z

Thank you, very helpful

bringe 2021-06-03T18:33:14.122400Z

Yes, there's a Calva command for that, Calva Diagnostics: Clojure-lsp Server Info .

❤️ 1
🎉 1