lsp

Eva O 2025-03-14T11:44:56.825809Z

How do I exclude a namespace from being sorted when I clean the namespaces? I depend on require order in a cljs file

ericdallo 2025-03-14T11:46:13.426979Z

you cant', you can change the sort logic as explained https://clojure-lsp.io/settings/#require, but can't tell to not sort a single ns

Eva O 2025-03-14T11:47:37.297719Z

Can I change the sort logic of a single namespace?

ericdallo 2025-03-14T11:47:51.301229Z

no

Eva O 2025-03-14T11:48:36.470699Z

Can I change the sort logic so that namespaces without :as, :refer, etc. don't get sorted?

ericdallo 2025-03-14T11:49:04.896589Z

currently no as well

Eva O 2025-03-14T11:49:46.664619Z

So the only way to ensure that a side effecting namespace is loaded in the right order is to turn off sorting for my whole project?

ericdallo 2025-03-14T11:50:23.950799Z

depend on sort order is extremaly not advisable as it's easy to break things if sort is wrong and hard to understand how something works just because of the load order

Eva O 2025-03-14T11:50:53.218149Z

Unfortunately I am using a javascript framework that uses side effects in require

ericdallo 2025-03-14T11:50:55.717309Z

> So the only way to ensure that a side effecting namespace is loaded in the right order is to turn off sorting for my whole project? Or change the ns name to something, I still suggest not depend on load order

ericdallo 2025-03-14T11:51:24.232659Z

maybe you can try to (require 'your-ns) in some place at the start of the app

☝️ 2
Eva O 2025-03-14T11:52:16.745439Z

Do you know if that's possible with javascript?

ericdallo 2025-03-14T12:00:40.757949Z

Don't have the knowledge, but I suppose yes as you can load a require anywhere in the cljs code

borkdude 2025-03-14T12:02:29.818689Z

CLJS doesn't support dynamic require. But a (ugly) workaround might be to introduce a CLJS namespace by the name aaaa.this-has-to-go-first which then loads the JS library for you

imre 2025-03-14T12:18:57.806919Z

Make that first segment aaaaaargh so it better expresses frustration

😅 2
Eva O 2025-03-14T12:22:58.510869Z

I moved the side effecting code to javascript. Thanks for explaining the namespace sorting. I wish there was a way to exclude a single namespace but alas

borkdude 2025-03-14T12:23:55.045419Z

@ericdallo perhaps clojure-lsp could check if there is an unsorted warning from clj-kondo and if not, don't do the sorting? then people could use #_:clj-kondo/ignore

ericdallo 2025-03-14T12:26:15.854869Z

yeah, this feature on clojure-lsp is pretty complex and was created long time ago before we have clj-kondo findings about sort, it would be possible, but we would need to check if there is any missing warning for clj-kondo about this, especially the setting :clean :require :lexicographically setting