lsp

grzm 2025-12-07T17:24:22.152219Z

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?

grzm 2025-12-07T17:25:11.417089Z

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!"))

ericdallo 2025-12-07T17:25:23.964839Z

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

grzm 2025-12-07T17:26:26.070629Z

% 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

ericdallo 2025-12-07T17:26:56.707649Z

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

ericdallo 2025-12-07T17:27:03.033639Z

https://clojure-lsp.io/settings/

grzm 2025-12-07T17:30:52.599859Z

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

grzm 2025-12-07T17:31:35.164079Z

Does the config look right to you?

ericdallo 2025-12-07T17:32:43.763549Z

yes it does

ericdallo 2025-12-07T17:32:50.042399Z

it might be the regex

grzm 2025-12-07T17:34:54.375899Z

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

ericdallo 2025-12-07T17:35:14.082219Z

we apply https://github.com/clojure-lsp/clojure-lsp/blob/f555e4b89a1a3aa8aa9f66809f0d5e4dc034c61d/lib/src/clojure_lsp/shared.clj#L587 on the whole abs path, so maybe .*resources/.*

ericdallo 2025-12-07T17:35:34.476419Z

yeah, that sound best for your case

grzm 2025-12-07T17:36:17.699539Z

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

ericdallo 2025-12-07T17:37:55.829299Z

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

grzm 2025-12-07T17:39:47.947189Z

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

❤️ 2