Fork me on GitHub
#lsp
<
2023-02-27
>
ericdallo12:02:09

clojure-lsp Released clojure-lsp https://github.com/clojure-lsp/clojure-lsp/releases/tag/2023.02.26-23.46.05 with fixes and improvements 🎉 There are improvements in hover being able to follow :arglists for documentation, support for cljs docs search on clojuredocs, big performance improvement in completion and more improvements! • General ◦ Add new setting :paths-ignore-regex to allow ignore analyzing/linting specific paths, useful if you have folders or files that are not relevant to be linted and are huge which may affect performance. ◦ Bump clj-kondo. Fixes missing lint class constructors, making clojure-lsp show add import code action always. ◦ Fix wrong ns rename for cljc files. https://github.com/clojure-lsp/clojure-lsp/issues/1508 • Editor ◦ Fix cache issue: wrong external dependencies analysis when running clojure-lsp in editor after running on CLI, affecting navigation. https://github.com/clojure-lsp/clojure-lsp/issues/1473 ◦ Bump lsp4clj fixing progress notifications during initialization for Calva. ◦ Allow go to definition of namespace even when the var is not known. Ex: clojure.string/foo will go to the definition of clojure.string. This is useful for cases where the var was not created yet but user wants to go to the ns to check the available functions or check the correct name of the function. ◦ Avoid basing results on old analysis. ◦ Add new setting :completion :analysis-type to choose between :fast-but-stale(default) or :slow-but-accurate, this should define whether completion should wait for changes that may still happening, this by default reverts the behavior introduced after https://github.com/clojure-lsp/clojure-lsp/issues/1425. https://github.com/clojure-lsp/clojure-lsp/issues/1487 ◦ Fix textDocument/hover issue when doc metadata isn't a string literal. ◦ Follow references to other vars in doc metadata for use in textDocument/hover. ◦ Support :arglists meta when finding docs of functions via hover feature. https://github.com/clojure-lsp/clojure-lsp/issues/1504 ◦ Enhance hover to search clojuredocs on CLJS. https://github.com/clojure-lsp/clojure-lsp/issues/1506 Thank you for all sponsors and ClojuristsTogether clojurists-together💙

👍 9
clj-kondo 11
clojure-lsp 13
calva 9
emacs 7
gratitude 10
🎉 5
lispyclouds12:02:08

whenever im trying to do a textDocument/hover in my nvim i get this error now:

clojure_lsp: -32603: Internal error
for example, when trying to hover on the defn here: https://github.com/lispyclouds/dotfiles/blob/main/tasks/general/commit.clj#L14

lispyclouds12:02:27

dont see anything useful in the client side lsp logs

ericdallo12:02:03

Yeah, I'm working on that, it's a bug, I'm using eval and graal doesn't support that

ericdallo12:02:05

will do a hotfix

lispyclouds14:02:50

tried it with the dev build here: https://cirrus-ci.com/task/6733629292806144 and it works!

ericdallo14:02:00

thanks for testing!

dpsutton16:02:50

I’m getting some errors on lsp startup that are preventing navigation from working. Details in thread:

dpsutton16:02:59

com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine  PosixPlatformThreads.java:  203
            com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine       PlatformThreads.java:  775
                                                     java.lang.Thread.run                Thread.java:  829
                       java.util.concurrent.ThreadPoolExecutor$Worker.run    ThreadPoolExecutor.java:  628
                        java.util.concurrent.ThreadPoolExecutor.runWorker    ThreadPoolExecutor.java: 1128
                                      java.util.concurrent.FutureTask.run            FutureTask.java:  264
                                                                      ...                                 
                                      clojure.core/binding-conveyor-fn/fn                   core.clj: 2047
                             clojure-lsp.startup/analyze-source-paths!/fn                startup.clj:   73
                                    clojure-lsp.kondo/run-kondo-on-paths!                  kondo.clj:  328
                                             clojure-lsp.kondo/run-kondo!                  kondo.clj:  312
                                          clojure-lsp.kondo/run-kondo!/fn                  kondo.clj:  313
                                                      clj-kondo.core/run!                   core.clj:  224
                                                   clj-kondo.core/run!/fn                   core.clj:  225
                                 clojure-lsp.kondo/run-kondo-on-paths!/fn                  kondo.clj:  325
                                   clojure-lsp.kondo/custom-lint-project!                  kondo.clj:  213
                     clojure-lsp.feature.diagnostics/custom-lint-project!            diagnostics.clj:  230
                      clojure-lsp.feature.diagnostics/findings-of-project            diagnostics.clj:  215
                       clojure-lsp.feature.diagnostics/unused-public-vars            diagnostics.clj:  188
                                                         clojure.core/set                   core.clj: 4114
                                                     clojure.core/reduce1                   core.clj:  944
                                                  clojure.core/chunk-next                   core.clj:  710
                                                                      ...                                 
                                                      clojure.core/map/fn                   core.clj: 2763
                                                         clojure.core/seq                   core.clj:  139
                                                                      ...                                 
                                                   clojure.core/filter/fn                   core.clj: 2834
                                               clojure.core/complement/fn                   core.clj: 1455
                                                  clojure.core/partial/fn                   core.clj: 2648
    clojure-lsp.feature.diagnostics/exclude-public-diagnostic-definition?            diagnostics.clj:   65
                                              clojure.string/starts-with?                 string.clj:  365
java.lang.NullPointerException: 
from startup log

dpsutton16:02:15

and then this appears constantly:

2023-02-27T16:25:22.309Z  WARN [clojure-lsp.kondo:315] - Non-fatal error from clj-kondo: No configs copied.

dpsutton16:02:01

and then all navigation just reports no definition found for …

borkdude16:02:28

Maybe it helps to disable the unused public var linter ;)

ericdallo16:02:56

only on latest release @U11BV7MTK?

dpsutton16:02:35

yes. was previously working fine. i’m gonna try to disable the linter and see if that fixes it. and then rollback with linter enabled and should continue working?

ericdallo16:02:08

the exception happens https://github.com/clojure-lsp/clojure-lsp/blob/148222e32dedc5be06e02faee9e13c4dd77d7251/lib/src/clojure_lsp/feature/diagnostics.clj#L65, weird, some var-definition is missing a :name , we didn't change anything related to that in clojure-lsp IIRC

dpsutton16:02:43

i still get the error with the linter disabled

clojure-lsp.feature.diagnostics/exclude-public-diagnostic-definition?            diagnostics.clj:   65
                                              clojure.string/starts-with?                 string.clj:  365

borkdude16:02:19

Hmm, probably also an opportunity for performance, when people don't use the linter don't do the work?

dpsutton16:02:00

Downgrading to 2022.12.09-15.51.10 fixes navigation. Interestingly I’m seeing a bunch of

ARNING: error while trying to read hook for clojure.test/deftest: Unmatched delimiter: ), expected: ] to match [ at [11 10]
I think someone fixed this on our side recently i’m just on a few days old branch. I don’t know if that could impact it or not

ericdallo16:02:04

that warning is probably not related

ericdallo16:02:24

@U11BV7MTK could you confirm the issue happens on jan release as well? there was indeed code changes in that release

ericdallo16:02:03

would be nice if I can repro that, is that metabase?

dpsutton16:02:41

issue not present on the link you sent for the jan release. no error in startup log. Yes it is metabase

ericdallo16:02:16

thanks, will try it myself and let you know

🙏 2
ericdallo16:02:34

Found it, maybe it's a bug on clj-kondo The exception when analyzing defclause https://github.com/metabase/metabase/blob/07f174deaaf3ee7794e17c3aa9ebf94250b04d8e/shared/src/metabase/mbql/schema.cljc#L986, this is a analysis with the name nil which AFAIK should not happen:

{:end-row 984,
 :meta {},
 :name-end-col 82,
 :external? false,
 :name-end-row 983,
 :name-row 983,
 :ns metabase.mbql.schema,
 :name nil,
 :lang :clj,
 :col 1,
 :name-col 70,
 :uri "file:///home/greg/dev/metabase/shared/src/metabase/mbql/schema.cljc",
 :end-col 44,
 :bucket :var-definitions,
 :row 983}

ericdallo17:02:07

I noticed that macro is configured as a lint-as in clj-kondo config clj-kondo.lint-as/def-catch-all

borkdude17:02:22

is this configured with def-catch-all, this had a change recently in clj-kondo which should have been an improvement ;)

borkdude17:02:33

the improvement was that locations were added

👍 2
borkdude17:02:49

I don't recall removing the name though ;)

ericdallo17:02:44

@U11BV7MTK would you mind creating that issue in clj-kondo later with those details of that macro please?

borkdude17:02:33

can you reproduce the issue with clj-kondo only? the analysis of the defclause defined vars should have a name

borkdude17:02:50

borkdude@m1 ~/temp/lint_as $ clj-kondo --lint src/my_lib.clj --config '{:analysis true :output {:format :edn}}' | jet -t ':analysis :var-definitions'
[{:col 1,
  :defined-by clojure.core/defmacro,
  :end-col 31,
  :end-row 3,
  :filename "src/my_lib.clj",
  :macro true,
  :name defclause,
  :name-col 11,
  :name-end-col 20,
  :name-end-row 3,
  :name-row 3,
  :ns my-lib,
  :row 3,
  :varargs-min-arity 0}
 {:col 1,
  :end-col 44,
  :end-row 6,
  :filename "src/my_lib.clj",
  :name median,
  :name-col 62,
  :name-end-col 68,
  :name-end-row 5,
  :name-row 5,
  :ns my-lib,
  :row 5}]
(ns my-lib)

(defmacro defclause [& _args])

(defclause ^{:requires-features #{:percentile-aggregations}} median
  field-or-expression FieldOrExpressionDef)
{:lint-as {my-lib/defclause clj-kondo.lint-as/def-catch-all}}

dpsutton18:02:59

sorry just out of a meeting. Is that a sufficient repro? Or shall i make an issue?

borkdude18:02:38

This isn't a repro: it shows the name is there so it's more of a counter-repro

borkdude18:02:51

But if you can provide a repro in the above format, that would be sweet

robert-stuttaford18:02:56

thank you for reporting this @U11BV7MTK

dpsutton18:02:15

having trouble identifying any blank names on my side

clj-kondo/clj-kondo          {:mvn/version "2023.02.17"}
and then with the api:
(def x (clj-kondo/run! {:lint ["src"]
                          :config {:analysis true
                                   :output {:format :edn}}
                          :config-dir ".clj-kondo"}))

kondo=> (count (->> x :analysis :var-definitions (filter (comp nil? :name))))
0

ericdallo18:02:01

yeah, I suspect it's something with that ns or any extra kondo config that metabase does differently

dpsutton18:02:24

ah, i didn’t have that classpath root

kondo=> (->> x :analysis :var-definitions (filter (comp nil? :name)))
({:end-row 984,
  :name-end-col 82,
  :name-end-row 983,
  :name-row 983,
  :ns metabase.mbql.schema,
  :name nil,
  :lang :clj,
  :filename "shared/src/metabase/mbql/schema.cljc",
  :col 1,
  :name-col 70,
  :end-col 44,
  :row 983}
 {:end-row 984,
  :name-end-col 82,
  :name-end-row 983,
  :name-row 983,
  :ns metabase.mbql.schema,
  :name nil,
  :lang :cljs,
  :filename "shared/src/metabase/mbql/schema.cljc",
  :col 1,
  :name-col 70,
  :end-col 44,
  :row 983})

👍 2
borkdude18:02:42

and what is at the location at the source? e.g. can you narrow the repro down to only that source snippet?

dpsutton18:02:04

(declare ag:var) ;; for clj-kondo
(defclause ^{:requires-features #{:standard-deviation-aggregations}} [ag:var var]
  field-or-expression FieldOrExpressionDef)

dpsutton18:02:20

ag:var looks suspicious

😮 2
dpsutton18:02:52

but repro finds it:

❯ echo '(declare ag:var)' | clj-kondo --config '{:analysis true :output {:format :edn}}' --lint - | jet -t ':analysis :var-definitions'
[{:col 1,
  :defined-by clojure.core/declare,
  :end-col 17,
  :end-row 1,
  :filename "<stdin>",
  :name ag:var,
  :name-col 10,
  :name-end-col 16,
  :name-end-row 1,
  :name-row 1,
  :ns user,
  :row 1}]

ericdallo18:02:25

I can repro the issue with @U04V15CAJ’s repro but with this code:

(defclause ^{:requires-features #{:standard-deviation-aggregations}} [ag:var var]
  field-or-expression FieldOrExpressionDef)

borkdude18:02:27

def-catch-all expects a symbol at that location

☝️ 2
borkdude18:02:29

with custom syntax like this, it might be better to write a hook (:macroexpand hook is easiest and sufficient for this one probably)

👍 2
dpsutton18:02:06

ah right. i’m linting the wrong line

dpsutton18:02:04

i got confused by the two results thinking it was the two forms. but it’s from clj and cljs analysis

dpsutton19:02:25

looks like the previous kondo (“2023.01.16”) also reported a nil name

{:filename "shared/src/metabase/mbql/schema.cljc",
  :row nil,
  :col nil,
  :ns metabase.mbql.schema,
  :name nil,
  :lang :clj}
but also excluded row and col information. Current kondo reports
{:end-row 984,
  :name-end-col 82,
  :name-end-row 983,
  :name-row 983,
  :ns metabase.mbql.schema,
  :name nil,
  :lang :clj,
  :filename "shared/src/metabase/mbql/schema.cljc",
  :col 1,
  :name-col 70,
  :end-col 44,
  :row 983}

borkdude19:02:58

yes, I think clojure-lsp skips things with nil locations

borkdude19:02:09

but it should probably skip things with nil names ;)

ericdallo19:02:32

yeah, it never occurred that could come nil from kondo, maybe we should

borkdude19:02:12

clj-kondo could also not include this nil-name var, but then it would maybe also harder to debug things

ericdallo19:02:40

Yeah, I think so

dpsutton19:02:06

it’s interesting it knows the length of the name (70 - 82) but doesn’t grab the name

ericdallo19:02:55

because it's the length of the vector, but [ag:var var] it's not really a name of a var-definition

borkdude19:02:31

I think it does (:value node) which normally returns the symbol

borkdude19:02:38

but in the case of a vector node it's nil

dpsutton19:02:36

Ah. Right. I was focusing on the colon in the name. But the vector doesn’t make sense at all. Sorry I’m playing catch-up on that

robert-stuttaford15:02:16

have we arrived at a conclusion? will it be fixed? 😅

ericdallo15:02:23

AFAICS it should be fixed in metabase repo itself, defining a hook for that macro

👍 2
borkdude16:02:10

@U11BV7MTK Happy to do that later this week, if you want me to do it

dpsutton16:02:04

I agree that there should be a fix in metabase. But seems lsp/kondo should be more resilient and not fail?

ericdallo16:02:08

yes, we should filter nameless var-definitions in clojure-lsp or kondo, I'm ok doing it on clojure-lsp so feel free to open an issue there

borkdude16:02:48

maybe we should submit a PR to clojure to not NPE on string functions :P

😂 2
robert-stuttaford16:02:06

ok, so i need to debug why my personal setup broke with the latest release from first principles, gotcha

dpsutton16:02:25

if it’s the same stacktrace as I was seeing,

(ns nocommit.kondo
  (:require [clj-kondo.core :as clj-kondo]
            [clojure.string :as str]))

  (def x (clj-kondo/run! {:lint ["src"
                                 ;; and your other source paths
                                 ]
                          :config {:analysis true
                                   :output {:format :edn}}
                          :config-dir ".clj-kondo"}))

(count (->> x :analysis :var-definitions (filter (comp nil? :name))))

dpsutton16:02:31

https://github.com/clojure-lsp/clojure-lsp/issues/1510 in clojure-lsp. Thank you all for the help

👍 6