Fork me on GitHub
#lsp
<
2021-03-23
>
dpsutton14:03:09

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

ericdallo14:03:39

Not that I know, what would be the suggested behavior in your opinion?

borkdude14:03:40

Note that clj-kondo also has a linter for unsorted namespaces so whatever LSP does it should conform with the linter

borkdude14:03:49

else you will get warnings even after sorting

ericdallo14:03:19

Yes, I think clojure-lsp is doing the same sorting as the linter

ericdallo14:03:26

otherwise let me know

dpsutton14:03:28

to me [zebra class] should come after apple. ie, it should be alphabetical regardless of the bracket presence or not

dpsutton14:03:31

or you risk getting an odd separation

(:import
   a1
   b1
   z1
   [a2 class]
   [b2 class]
   [z2 class])

borkdude14:03:34

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

ericdallo14:03:53

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

dpsutton14:03:55

(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

dpsutton14:03:14

oh, kondo is opinionated in that manner as well?

borkdude14:03:42

it's not opinionated, it just took over what the most popular tooling already did

borkdude14:03:56

e.g. when I clojure-sort-ns in emacs, I want the warnings to go away

dpsutton14:03:29

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

borkdude14:03:03

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

dpsutton14:03:37

cool. just bringing it up. i was surprised to not have seen it before

borkdude14:03:41

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)

dpsutton14:03:57

i've only been testing on imports

borkdude14:03:17

clj-kondo doesn't have any rules for imports currently

dpsutton14:03:22

that's my preferred behavior there. the [ character does not affect sorting.

borkdude14:03:23

but the same sorting would apply if it had

dpsutton14:03:30

ah, so its just lsp then i guess

borkdude14:03:02

oh yeah, I think clojure-sort-ns ignores the [ as well

ericdallo14:03:13

ok, sou we could fix on lsp 🙂

borkdude14:03:25

Note that you have to enable :linters {:unsorted-required-namespaces {:level :warning}}

borkdude14:03:37

we could add :unsorted-imports as well

ericdallo14:03:58

@U11BV7MTK please open a issue so we can prioritize that fix

dpsutton14:03:13

awesome. thank you all. i'm doing an issue and already have a failing test case

borkdude14:03:29

ah, clojure-sort-ns also sorts imports, awesome

dpsutton14:03:57

in clojure-mode?

dpsutton14:03:20

oof, and there's disagreement about casing. its putting java.util.Locale before java.util.concurrent.TimeoutException because L comes before c 😕

borkdude14:03:17

I think it's right on that

dpsutton14:03:52

then lsp has another bug report 🙂

ericdallo16:03:07

Fixed @U11BV7MTK!

🎉 3
Shantanu Kumar20:03:12

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.)

borkdude20:03:12

@kumarshantanu take a look in the Makefile

ericdallo20:03:41

make test should do it

borkdude20:03:31

This is what I want to accomplish with the bb task runner: have an easy overview of what you can do in a project

ericdallo20:03:46

cool 😄 !

ericdallo20:03:59

bb for the rescue

borkdude20:03:15

I wonder why are the debug-bin and prod-bin tasks not "phony"?

ericdallo20:03:28

forgot to add them 😅

borkdude20:03:32

I'm trying to understand how projects use Makefile, I think usually just for invoking common tasks

yes 3
borkdude20:03:48

and hardly for any more advanced features

borkdude20:03:17

like "prevent this step if file produced is newer than this or that", I hardly see that anymore

ericdallo20:03:52

yes, in my experience, there are projects with simple tasks like clojure-lsp, lsp-mode and projects with makefiles like emacs-ng

ericdallo20:03:10

but I don't know the common in clojure ones

chepprey20:03:58

"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.

borkdude20:03:06

@UHL84CDTP That is was it was made for but I see it being used with almost all tasks "phony" in many projects, including clojure-lsp

borkdude20:03:18

Maybe there are clojure projects who use make to skip compiling an uberjar if sources haven't changed?

borkdude20:03:23

Examples of this are welcome

chepprey20:03:37

Googled "make phony" and now I understand. Haven't used make regularly since the 90s 😆

chepprey20:03:22

Ya, if everything in a Makefile is tagged phony, seems like wrong tool for the job.

Shantanu Kumar20:03:28

Thanks! Didn't notice the Makefile.