lsp 2025-12-07

Hello! I like clojure-lsp format provides cljfmt. I've got some large edn files in my repo (test resources) that I'd like to exclude from formatting. I'm supplying the paths I'd like . This works when calling cljfmt directly, but not when using clojure-lsp format . I believe clojure-lsp is ignoring this and using the paths it derives from my deps.edn instead. I'm I correct in my assumption? Is there currently a way to have clojure-lsp format ignore directories that are otherwise included in the project?

Example:

% cat deps.edn 
{:paths ["src" "resources"]}
% cat .cljfmt.edn 
{:paths ["src"]}
% cat resources/data.edn 
{:not
 "formatted"}
% cat src/com/grzm/ex/cljlsp_format.clj 
(ns com.grzm.ex.cljlsp-format)

(defn -main
  "please format me!"
  [& _args]
  (println "Hello, world!"))

Yes, you can exclude the edn files from the source-paths, there are some ways to do that:

% clojure-lsp format
[ 99%] Project analyzed            Formatting namespaces...
Formatted data
Formatted com.grzm.ex.cljlsp-format
Formatted 2 namespaces
# reset
% git co .
Updated 2 paths from the index
% cljfmt fix        
Reformatted src/com/grzm/ex/cljlsp_format.clj

I believe the best here is configure :paths-ignore-regex clojure-lsp config

Cheers. It looks like I'm not spelling something right:

% cat .lsp/config.edn 
{:paths-ignore-regex ["resources/.*"]}
% clojure-lsp format
[ 99%] Project analyzed            Formatting namespaces...
Formatted data
Formatted com.grzm.ex.cljlsp-format
Formatted 2 namespaces
% tree .
.
├── deps.edn
├── resources
│   └── data.edn
└── src
    └── com
        └── grzm
            └── ex
                └── cljlsp_format.clj

6 directories, 3 files

Does the config look right to you?

yes it does

it might be the regex

Looks like I should use :source-paths-ignore-regex if I want to use paths relative to the project:

% cat .lsp/config.edn 
{:source-paths-ignore-regex ["resources"]}
% clojure-lsp format 
[ 99%] Project analyzed            Formatting namespaces...
Formatted com.grzm.ex.cljlsp-format
Formatted 1 namespaces

yeah, that sound best for your case

Kinda surprised that if I include the / it doesn't work:

% cat .lsp/config.edn 
{:source-paths-ignore-regex ["resources/"]}
% clojure-lsp format 
[ 99%] Project analyzed            Formatting namespaces...
Formatted data
Formatted com.grzm.ex.cljlsp-format
Formatted 2 namespaces

yeah that's always tricky, we should add examples I guess

Thanks for the assist! (and it was good to meet you at the Conj!)

❤️ 2