lsp

:clojure-lsp: Clojure implementation of the Language Server Protocol: https://clojure-lsp.io/
ericdallo 2021-01-21T01:40:32.001400Z

Hey @borkdude about the unresolved-other-ns feature on latest clj-kondo, I'm testing it with clojure-lsp and it seems is not working properly

borkdude 2021-01-21T08:03:22.004500Z

The warning will only show if the ns was analyzed

ericdallo 2021-01-21T12:16:41.009300Z

@snoe any clue why this happen?

borkdude 2021-01-21T12:20:03.009500Z

@ericdallo you can check .clj-kondo/.cache/<your-version>/clj/rewrite-clj/... to see if clj-kondo in fact analyzed this jar

borkdude 2021-01-21T12:20:32.009700Z

(please note that this data is implementation detail and should not be used by other tools)

πŸ‘ 1
ericdallo 2021-01-21T12:25:46.010Z

Odd, it was analyzed indeed:

ericdallo 2021-01-21T12:26:29.010400Z

wait, the rewrite-clj.zip is not in there

borkdude 2021-01-21T12:26:57.010600Z

I will try locally. Which version of rewrite-clj is this?

ericdallo 2021-01-21T12:27:32.010800Z

rewrite-clj/rewrite-clj {:local/root "lib/rewrite-clj-0.6.2-SNAPSHOT.jar"}

ericdallo 2021-01-21T12:28:12.011Z

We can replace the local jar with the clojars released recently

ericdallo 2021-01-21T12:29:07.011200Z

oh, maybe this could be the issue? the jar is on clojure-lsp/lib , so clj-kondo is not scanning it propertly

borkdude 2021-01-21T12:29:37.011400Z

when I do this:

clj-kondo --lint $(clojure -Spath -Sdeps '{:deps {rewrite-clj/rewrite-clj {:mvn/version "RELEASE"}}}')
I do get the correct ones.

borkdude 2021-01-21T12:30:10.011600Z

if you lint the deps using your deps.edn using -Spath clj-kondo should be able to find it

ericdallo 2021-01-21T12:30:11.011800Z

yeah, probably if we use the jar from clojars like the others may work

ericdallo 2021-01-21T12:30:36.012Z

yeah the issue is that the lib folder is not in the clojure-lsp classpath to scan

ericdallo 2021-01-21T12:30:52.012200Z

I'll try changing it to use the rewrite-clj from clojars

borkdude 2021-01-21T12:31:40.012400Z

Btw, if you provide the option :no-warnings then clj-kondo will cache jars and won't lint them again (when the same option is used again)

borkdude 2021-01-21T12:32:05.012600Z

There is also :parallel true for faster linting

ericdallo 2021-01-21T12:32:18.012800Z

oh, that certainly will be useful

borkdude 2021-01-21T12:32:23.013Z

this is only useful when using a classpath, as it only lints jars in parallel

ericdallo 2021-01-21T12:32:55.013200Z

yes, I'll test it setting that to true on classpath scans

ericdallo 2021-01-21T12:37:37.013400Z

Hum, using the jar from maven did not work, still I can't find the rewrite-clj.zip and rewrite-clj.node analysis on .clj-kondo/.cache folder

borkdude 2021-01-21T12:38:28.013600Z

I can't repro this using clj-kondo only 🀷

borkdude 2021-01-21T12:39:21.013800Z

if you can make a command line clj-kondo repro, I will look into it

ericdallo 2021-01-21T12:44:07.014Z

the paralell option seems to have a huge startup improvement for clojure-lsp πŸ˜„ thank you! I'll try to reproduce the issue with rewrite-clj with kondo only, (I don't have clj-kondo installed yet since I have NixOS and is not updated with your last release yet πŸ˜…)

borkdude 2021-01-21T12:45:04.014200Z

@ericdallo You can also use it from the JVM with clojure -Sdeps

borkdude 2021-01-21T12:45:12.014400Z

or lein or whatever :)

ericdallo 2021-01-21T12:45:59.014600Z

oh, right, so I can lein run or something like that?

borkdude 2021-01-21T12:47:56.014800Z

Yeah, you can follow this README: https://github.com/clj-kondo/clj-kondo/blob/master/doc/jvm.md

πŸ‘€ 1
borkdude 2021-01-21T12:48:39.015200Z

clj -Sdeps '{:deps {clj-kondo {:mvn/version "RELEASE"}}}' -m clj-kondo.main --lint $(clojure -Spath)

ericdallo 2021-01-21T13:07:16.017Z

Thanks, I managed to run now, I ran this way:

clj -Sdeps '{:deps {clj-kondo {:mvn/version "2021.01.20"}}}' -m clj-kondo.main --lint  $(clojure -Spath -Sdeps '{:deps {rewrite-clj/rewrite-clj {:mvn/version "0.6.1"}}}')

borkdude 2021-01-21T13:07:39.017200Z

should work

ericdallo 2021-01-21T13:09:30.017400Z

It seems that indeed linted rewrite-clj.zip , I cannot find on .clj-kondo/.cache though

borkdude 2021-01-21T13:12:51.017600Z

Hmm, indeed:

borkdude@MBP2019 /tmp/foobar $ clojure -Sdeps '{:deps {clj-kondo {:mvn/version "2021.01.20"}}}' -m clj-kondo.main --no-warnings --lint  $(clojure -Spath -Sdeps '{:deps {rewrite-clj/rewrite-clj {:mvn/version "RELEASE"}}}')
WARNING: When invoking clojure.main, use -M
borkdude@MBP2019 /tmp/foobar $ find . | grep rewrite-clj.zip
./.clj-kondo/.cache/2021.01.20/clj/rewrite-clj.zip.seq.transit.json
./.clj-kondo/.cache/2021.01.20/clj/rewrite-clj.zip.walk.transit.json
./.clj-kondo/.cache/2021.01.20/clj/rewrite-clj.zip.move.transit.json
./.clj-kondo/.cache/2021.01.20/clj/rewrite-clj.zip.whitespace.transit.json
./.clj-kondo/.cache/2021.01.20/clj/rewrite-clj.zip.insert.transit.json
./.clj-kondo/.cache/2021.01.20/clj/rewrite-clj.zip.subedit.transit.json
./.clj-kondo/.cache/2021.01.20/clj/rewrite-clj.zip.find.transit.json
./.clj-kondo/.cache/2021.01.20/clj/rewrite-clj.zip.base.transit.json
./.clj-kondo/.cache/2021.01.20/clj/rewrite-clj.zip.edit.transit.json
./.clj-kondo/.cache/2021.01.20/clj/rewrite-clj.zip.transit.json
./.clj-kondo/.cache/2021.01.20/clj/rewrite-clj.zip.remove.transit.json

borkdude 2021-01-21T13:13:08.017800Z

I'll take a look

ericdallo 2021-01-21T13:16:25.018Z

thank you πŸ˜„ !

borkdude 2021-01-21T13:43:13.018200Z

Oh, it is there after all:

./.clj-kondo/.cache/2021.01.20/clj/rewrite-clj.zip.transit.json

borkdude 2021-01-21T13:43:58.018400Z

$ cat .clj-kondo/.cache/2021.01.20/clj/rewrite-clj.zip.transit.json | jet --from transit | puget
{->root-string {:col 1,
                :deprecated "0.4.0",
                :fixed-arities #{1},
                :name ->root-string,
                :ns rewrite-clj.zip,
                :row 116,
                :top-ns rewrite-clj.zip},
 ->string {:col 1,
           :deprecated "0.4.0",
           :fixed-arities #{1},
           :name ->string,
           :ns rewrite-clj.zip,
           :row 111,
           :top-ns rewrite-clj.zip},
 defbase {:col 1,
          :fixed-arities #{2},
          :macro true,
          :name defbase,
          :ns rewrite-clj.zip,
          :private true,
          :row 83,
          :top-ns rewrite-clj.zip}}

borkdude 2021-01-21T13:44:33.018600Z

so all seems good on the clj-kondo side

ericdallo 2021-01-21T13:49:01.018800Z

Yeah, I found it, I'll look closely again via clojure-lsp if it's missing or not

ericdallo 2021-01-21T17:30:40.019400Z

I could reproduce the issue with other lib matcher-combinators and I could find indeed the cache transit: .clj-kondo/.cache/2021.01.20/clj/matcher-combinators.midje.transit.json

ericdallo 2021-01-21T17:31:13.019800Z

clojure-lsp just use the findings to produce those diagnostics, there is no parsing

ericdallo 2021-01-21T22:59:29.020Z

@borkdude it seems the transit does not contain some methods, for example, I could reproduce again with digest lib on clojure-lsp and when I :

cat .clj-kondo/.cache/2021.01.20/clj/digest.transit.json | lein jet --from transit --to json |jq .
it returns:
{
  "create-fn!": {
    "row": 83,
    "col": 1,
    "fixed-arities": [
      1
    ],
    "name": "create-fn!",
    "ns": "digest",
    "top-ns": "digest"
  },
  "Digestible": {
    "row": 35,
    "col": 1,
    "name": "Digestible",
    "ns": "digest",
    "top-ns": "digest"
  },
  "create-fns": {
    "row": 94,
    "col": 1,
    "private": true,
    "fixed-arities": [
      0
    ],
    "name": "create-fns",
    "ns": "digest",
    "top-ns": "digest"
  },
  "-digest": {
    "row": 35,
    "col": 1,
    "fixed-arities": [
      2
    ],
    "name": "-digest",
    "ns": "digest",
    "top-ns": "digest"
  },
  "signature": {
    "row": 27,
    "col": 1,
    "private": true,
    "fixed-arities": [
      1
    ],
    "name": "signature",
    "ns": "digest",
    "top-ns": "digest",
    "arities": {
      "1": {
        "ret": "string"
      }
    }
  },
  "digest": {
    "row": 70,
    "col": 1,
    "fixed-arities": [
      2
    ],
    "name": "digest",
    "ns": "digest",
    "top-ns": "digest"
  },
  "byte-seq": {
    "row": 22,
    "col": 1,
    "private": true,
    "fixed-arities": [
      1
    ],
    "name": "byte-seq",
    "ns": "digest",
    "top-ns": "digest",
    "arities": {
      "1": {
        "ret": "seq"
      }
    }
  },
  "read-some": {
    "row": 13,
    "col": 1,
    "private": true,
    "fixed-arities": [
      1
    ],
    "name": "read-some",
    "ns": "digest",
    "top-ns": "digest"
  },
  "algorithms": {
    "row": 75,
    "col": 1,
    "fixed-arities": [
      0
    ],
    "name": "algorithms",
    "ns": "digest",
    "top-ns": "digest",
    "arities": {
      "0": {
        "ret": "set"
      }
    }
  },
  "*buffer-size*": {
    "row": 11,
    "col": 1,
    "name": "*buffer-size*",
    "ns": "digest",
    "top-ns": "digest"
  }
}
it seems it's missing some functions like md5 which clojure-lsp uses:

borkdude 2021-01-21T23:01:12.020400Z

and how is this digest function defined?

ericdallo 2021-01-21T23:01:57.020600Z

the same is happening with rewrite-clj.zip:

ericdallo 2021-01-21T23:02:06.021Z

it's just a required lib: https://github.com/clojure-lsp/clojure-lsp/blob/master/src/clojure_lsp/crawler.clj#L15

ericdallo 2021-01-21T23:02:39.021300Z

this is ours deps.edn: https://github.com/clojure-lsp/clojure-lsp/blob/master/deps.edn#L17

borkdude 2021-01-21T23:03:15.021600Z

Please make a small repro, isolated from any other tools (not depending on LSP for example), just using deps.edn and clj-kondo JVM. Then I'll look into it tomorrow It's past midnight here.

borkdude 2021-01-21T23:03:41.021800Z

File it as an issue on the clj-kondo github if you can make a repro.

ericdallo 2021-01-21T23:04:04.022100Z

sure, thanks πŸ˜„

ericdallo 2021-01-21T23:04:09.022300Z

good night πŸ˜‰

borkdude 2021-01-21T23:04:21.022500Z

Thanks πŸ’€

ericdallo 2021-01-21T01:41:32.001700Z

It seems to report unused var from external deps

ericdallo 2021-01-21T01:41:50.002200Z

ericdallo 2021-01-21T01:44:23.002600Z

I could only reproduce with rewrite-clj.zip`` and rewrite-clj.node for some reason :thinking_face:

ericdallo 2021-01-21T01:48:39.002800Z

Hum, I think clj-kondo is not scanning rewrite-clj jar correcly, what is causing that, maybe we should not show the lint if the analysis was not done properly?

ericdallo 2021-01-21T01:49:39.003Z

Also, I'm not sure how can I check if rewrite-clj was analyzed properly, I can only say it does not shows up on clj-kondo analysis output

codeasone 2021-01-21T10:28:31.006500Z

clojure-lsp doesn't seem to be parsing my cljs code. I'd really appreciate jump-to and find-references support for cljs ootb. Is this supported? Perhaps it's something I've misconfigured my end?

codeasone 2021-01-21T10:32:35.007Z

> source-pathsΒ value is a set of project-local directories to look for clj/cljc/cljs files

codeasone 2021-01-21T10:33:09.007600Z

Great, looks like it was operator error

codeasone 2021-01-21T10:48:23.009Z

If anyone has any input on optimising clojure-lsp for clj/cljc/cljs projects I'd appreciate tips/experience reports. I'm hooking into it via lsp-mode in combination with cider at the moment.

ericdallo 2021-01-21T12:12:06.009100Z

I'm don't have much experience with cljs, but what kind of issues you have?

codeasone 2021-01-21T12:53:15.015400Z

When I try to lsp-goto-implementation (with the clojure-lsp started) I'm getting:

The connected server(s) does not support method textDocument/implementation.
Here's the output of lsp-describe-session
`-[-] clojure-lsp:56843
    |-[-] Buffers
    |  |-[+] cards.cljc<components>
    |  |-[+] cards.cljc<specs>
    |  `-[+] system.clj
    `-[-] Capabilities
       |-[-] semanticTokensProvider:
       |  |-[X] full: t
       |  |-[X] range: t
       |  `-[-] legend:
       |     |-[X] tokenModifiers: []
       |     `-[X] tokenTypes: [type function macro]
       |-[X] callHierarchyProvider: t
       |-[-] executeCommandProvider:
       |  `-[X] commands: [add-missing-libspec add-import-to-namespace cycle-privacy thread-last-all unwind-all move-to-let clean-ns thread-last introduce-let unwind-thread thread-first-all thread-first inline-symbol extract-function cycle-coll expand-let]
       |-[X] renameProvider: t
       |-[X] documentRangeFormattingProvider: t
       |-[X] documentFormattingProvider: t
       |-[-] codeLensProvider:
       |  `-[X] resolveProvider: t
       |-[X] codeActionProvider: t
       |-[X] workspaceSymbolProvider: t
       |-[X] documentSymbolProvider: t
       |-[X] documentHighlightProvider: t
       |-[X] referencesProvider: t
       |-[X] definitionProvider: t
       |-[-] completionProvider:
       |  |-[X] triggerCharacters: []
       |  `-[X] resolveProvider: t
       |-[X] hoverProvider: t
       `-[-] textDocumentSync:
          |-[-] save:
          |  `-[X] includeText: t
          |-[X] change: 1
          `-[X] openClose: t
I'm just getting started with lsp so apologies if there something obviously poorly configured my side.

codeasone 2021-01-21T12:55:07.015600Z

lsp-find-references on the other hand is now actually working great with cljc and cljs πŸŽ‰

ericdallo 2021-01-21T12:59:48.015800Z

yeah, clojure-lsp don't have lsp-find-implementation implemented, we just have lsp-find-definition

ericdallo 2021-01-21T13:00:06.016Z

implementation makes sense to go to interface implementations and etc, it's not really useful for clojure

ericdallo 2021-01-21T13:00:26.016200Z

find-definition on other hand is what makes sense for clojure

ericdallo 2021-01-21T13:00:46.016400Z

lsp-find-definition should work for you

πŸ‘ 1
ericdallo 2021-01-21T13:01:32.016600Z

@codeasone this could help you πŸ™‚ https://emacs-lsp.github.io/lsp-mode/tutorials/clojure-guide/