is there an issue for namespace sorting that imports (not required) seems to include brackets in sorting? Ie, it will sort (import [zebra] apple)
as it seems to think [
comes before a
which might be true but not really in the spirit of the alphabet
Not that I know, what would be the suggested behavior in your opinion?
Note that clj-kondo also has a linter for unsorted namespaces so whatever LSP does it should conform with the linter
else you will get warnings even after sorting
Yes, I think clojure-lsp is doing the same sorting as the linter
otherwise let me know
to me [zebra class] should come after apple. ie, it should be alphabetical regardless of the bracket presence or not
or you risk getting an odd separation
(:import
a1
b1
z1
[a2 class]
[b2 class]
[z2 class])
this is not how emacs clojure-mode, etc works. imo the exact way of sorting shouldn't matter as long as its consistent with the rest of the ecosystem, else people would be fighting against each other with different tooling
I think this could be the desired behaviour for some people but not for everybody, if we implement a flag for that on clojure-lsp, we could sort but clj-kondo linter would still complain about not corrected sorted unless we add a flag there as well
(testing "sorts according to symbols not brackets"
(test-clean-ns {}
(code "(ns foo.bar"
" (:import"
" [zebra import1]"
" apple))"
"import1."
"apple.")
(code "(ns foo.bar"
" (:import"
" apple"
" [zebra import1]))"
"import1."
"apple.")))
in transform_test
oh, kondo is opinionated in that manner as well?
it's not opinionated, it just took over what the most popular tooling already did
e.g. when I clojure-sort-ns in emacs, I want the warnings to go away
haha i for sure want the warnings to go away as well. we use a sorter currently and i can't quite reliably use lsp sorting because of this behavior
We could make the linter less strict so it would accept both, but I would like to preserve the old way as else it would be breaking
cool. just bringing it up. i was surprised to not have seen it before
Just to make clear, this gives a warning in clj-kondo:
(ns foo
(:require [foo]
a))
but this doesn't:
(ns foo
(:require a
[foo]))
(after sorting with clojure-sort-ns
in emacs)i've only been testing on imports
clj-kondo doesn't have any rules for imports currently
that's my preferred behavior there. the [
character does not affect sorting.
but the same sorting would apply if it had
ah, so its just lsp then i guess
oh yeah, I think clojure-sort-ns ignores the [
as well
ok, sou we could fix on lsp 🙂
Note that you have to enable :linters {:unsorted-required-namespaces {:level :warning}}
we could add :unsorted-imports
as well
@dpsutton please open a issue so we can prioritize that fix
Made an issue for kondo here: https://github.com/clj-kondo/clj-kondo/issues/1230
awesome. thank you all. i'm doing an issue and already have a failing test case
ah, clojure-sort-ns also sorts imports, awesome
in clojure-mode?
yes
oof, and there's disagreement about casing. its putting java.util.Locale
before java.util.concurrent.TimeoutException
because L
comes before c
😕
I think it's right on that
then lsp has another bug report 🙂
Fixed @dpsutton!
Can anybody tell me how to run the Clojure-LSP tests after cloning the repo? (Sorry, I'm not well versed with the deps.edn
way of doing things. I created a kaocha
executable script but to no avail.)
@kumarshantanu take a look in the Makefile
make test
should do it
Thanks! Didn't notice the Makefile
.
This is what I want to accomplish with the bb task runner: have an easy overview of what you can do in a project
cool 😄 !
bb for the rescue
I wonder why are the debug-bin and prod-bin tasks not "phony"?
forgot to add them 😅
I'm trying to understand how projects use Makefile, I think usually just for invoking common tasks
and hardly for any more advanced features
like "prevent this step if file produced is newer than this or that", I hardly see that anymore
yes, in my experience, there are projects with simple tasks like clojure-lsp, lsp-mode and projects with makefiles like emacs-ng
but I don't know the common in clojure ones
"advanced features" ... I always thought that THE thing that make did was to decide to do stuff based on comparing file timestamps. Primarily, to recompile the .o file (and relink the lib or exe) if the .c file has been updated.
@chepprey That is was it was made for but I see it being used with almost all tasks "phony" in many projects, including clojure-lsp
Maybe there are clojure projects who use make to skip compiling an uberjar if sources haven't changed?
Examples of this are welcome
Googled "make phony" and now I understand. Haven't used make regularly since the 90s 😆
Ya, if everything in a Makefile is tagged phony, seems like wrong tool for the job.