lsp 2025-10-22

Does anyone know how to tell clojure-lsp to use clj-kondo's configuration files? I've setup a .clj-kondo/config.edn that works for clj-kondo at the command line, but clojure-lsp still reports clj-kondo errors.

You need to set the correct project root

Are you in emacs?

Neovim currently - I've been trying it out.

Yeah, Clojure-lsp check kondo file from project root

LSP clients should have the responsibility to set the project root

I have the .clj-kondo config in my project root, with my .git. However, maybe clojure-lsp is looking at the subproject root. Let me try shifting the config down.

Not sure how to do that in neovim tho

usually LSP clients have commands to show that info, but Clojure-lsp logs should tell what project root is using too

Ah yes, that fixed it. I'm not going to worry too much about setting the project root if I can put the config file in the subdirectory.

If it works the same as VSCode: open your editor from the command line the project directory

It seemed to be independent of the editor's current directory.

@weavejester it might be a good thing to set correct project root, most clojure-lsp features relying on correct classpath string (spawning lein classpath on project root etc)

Do you have a deps.edn in the root ? That might help too?

So I have two projects within the same repository: cljfmt and lein-cljfmt. When I'm working on cljfmt/src/cljfmt/core.cljc, the project root for clojure-lsp is cljfmt. I think this is probably correct, as it's picking the directory that contains the project.clj file, rather than the repository root.

👍 1

I just needed to ensure that my clj-kondo config was in cljfmt/.clj-kondo/config.edn

makes sense

I have a suggestion that you can decide if it makes sense, it's what I did for clojure-lsp (which has 2 submodules, lib and cli) You can have a root deps.edn with just something like https://github.com/clojure-lsp/clojure-lsp/blob/master/deps.edn#L2-L5. and use the as clojure-lsp root, then you will be able to have both projects in clojure-lsp classpath so you dont need to change anything, but it's just a suggestion in case that's a problem (I really need to documentate this mono-repo support suggestion in a doc)

Thanks for the advice! I'm using the root deps.edn as a way of using cljfmt as a clojure tool, but if I add the local dependencies to the :dev alias it might work. That said, I don't really need to work on the Leiningen plugin for cljfmt these days.

You can setup the root_dir function for neovim lsp integration to first look for .clojure-lsp/config.edn and only if it doesn't find that, then look for deps.edn (and others): https://github.com/Deraen/dotfiles/blob/master/.vim/lua/plugins/lsp.lua#L131-L153

I think the default (IF you use nvim-lspconfig) is { "project.clj", "deps.edn", "build.boot", "shadow-cljs.edn", ".git", "bb.edn" }

👍 1