How do I exclude a namespace from being sorted when I clean the namespaces? I depend on require order in a cljs file
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
Can I change the sort logic of a single namespace?
no
Can I change the sort logic so that namespaces without :as, :refer, etc. don't get sorted?
currently no as well
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?
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
Unfortunately I am using a javascript framework that uses side effects in require
> 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
maybe you can try to (require 'your-ns) in some place at the start of the app
Do you know if that's possible with javascript?
Don't have the knowledge, but I suppose yes as you can load a require anywhere in the cljs code
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
Make that first segment aaaaaargh so it better expresses frustration
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
@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
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