Fork me on GitHub
#lsp
<
2021-06-03
>
Timofey Sitnikov11:06:18

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?

nbardiuk11:06:37

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

Ben11:06:37

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?

Ben12:06:56

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:

Ben12:06:30

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

ericdallo15:06:03

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

ericdallo15:06:26

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

Ben15:06:44

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?

ericdallo16:06:15

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}]

👍 3
ericdallo16:06:03

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

seancorfield16:06:25

@URQPRL0HK 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).

👍 6
seancorfield16:06:12

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

ericdallo16:06:27

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 @U9A1RLFNV?)

Ben17:06:20

Thank you, very helpful

bringe18:06:14

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

🎉 3
❤️ 3