lsp

:clojure-lsp: Clojure implementation of the Language Server Protocol: https://clojure-lsp.io/
dpsutton 2021-03-23T14:06:09.083100Z

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

ericdallo 2021-03-23T14:08:39.083200Z

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

borkdude 2021-03-23T14:10:40.083400Z

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

borkdude 2021-03-23T14:10:49.083600Z

else you will get warnings even after sorting

ericdallo 2021-03-23T14:14:19.083800Z

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

ericdallo 2021-03-23T14:14:26.084Z

otherwise let me know

dpsutton 2021-03-23T14:18:28.084200Z

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

dpsutton 2021-03-23T14:19:31.084400Z

or you risk getting an odd separation

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

borkdude 2021-03-23T14:19:34.084600Z

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

ericdallo 2021-03-23T14:19:53.084800Z

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

dpsutton 2021-03-23T14:19:55.085Z

(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

dpsutton 2021-03-23T14:20:14.085200Z

oh, kondo is opinionated in that manner as well?

borkdude 2021-03-23T14:20:42.085400Z

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

borkdude 2021-03-23T14:20:56.085600Z

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

dpsutton 2021-03-23T14:23:29.085800Z

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

dpsutton 2021-03-23T14:23:41.086Z

borkdude 2021-03-23T14:24:03.086400Z

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

dpsutton 2021-03-23T14:24:37.086600Z

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

borkdude 2021-03-23T14:28:41.086800Z

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)

dpsutton 2021-03-23T14:28:57.087Z

i've only been testing on imports

borkdude 2021-03-23T14:29:17.087200Z

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

dpsutton 2021-03-23T14:29:22.087400Z

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

borkdude 2021-03-23T14:29:23.087600Z

but the same sorting would apply if it had

dpsutton 2021-03-23T14:29:30.087800Z

ah, so its just lsp then i guess

borkdude 2021-03-23T14:30:02.088Z

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

ericdallo 2021-03-23T14:30:13.088200Z

ok, sou we could fix on lsp 🙂

borkdude 2021-03-23T14:30:25.088400Z

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

borkdude 2021-03-23T14:30:37.088600Z

we could add :unsorted-imports as well

ericdallo 2021-03-23T14:30:58.088800Z

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

borkdude 2021-03-23T14:32:47.089Z

Made an issue for kondo here: https://github.com/clj-kondo/clj-kondo/issues/1230

dpsutton 2021-03-23T14:33:13.089400Z

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

borkdude 2021-03-23T14:33:29.089600Z

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

dpsutton 2021-03-23T14:38:57.089800Z

in clojure-mode?

borkdude 2021-03-23T14:39:05.090Z

yes

dpsutton 2021-03-23T14:40:20.090200Z

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

borkdude 2021-03-23T14:43:17.090400Z

I think it's right on that

dpsutton 2021-03-23T14:43:52.090600Z

then lsp has another bug report 🙂

ericdallo 2021-03-23T16:28:07.090800Z

Fixed @dpsutton!

🎉 1
Shantanu Kumar 2021-03-23T20:33:12.092700Z

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

borkdude 2021-03-23T20:34:12.093Z

@kumarshantanu take a look in the Makefile

ericdallo 2021-03-23T20:34:41.093200Z

make test should do it

Shantanu Kumar 2021-03-23T20:35:28.093600Z

Thanks! Didn't notice the Makefile.

borkdude 2021-03-23T20:35:31.093700Z

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

ericdallo 2021-03-23T20:35:46.093900Z

cool 😄 !

ericdallo 2021-03-23T20:35:59.094100Z

bb for the rescue

borkdude 2021-03-23T20:36:15.094300Z

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

ericdallo 2021-03-23T20:36:28.094500Z

forgot to add them 😅

borkdude 2021-03-23T20:36:32.094700Z

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

1
borkdude 2021-03-23T20:36:48.095Z

and hardly for any more advanced features

borkdude 2021-03-23T20:37:17.095200Z

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

ericdallo 2021-03-23T20:37:52.095400Z

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

ericdallo 2021-03-23T20:38:10.095600Z

but I don't know the common in clojure ones

chepprey 2021-03-23T20:51:58.095900Z

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

borkdude 2021-03-23T20:53:06.096100Z

@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

borkdude 2021-03-23T20:54:18.096300Z

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

borkdude 2021-03-23T20:54:23.096500Z

Examples of this are welcome

chepprey 2021-03-23T20:55:37.096700Z

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

chepprey 2021-03-23T20:57:22.096900Z

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