Fork me on GitHub
#lsp
<
2021-12-04
>
Drew Verlee19:12:32

(ns toy.m1)

::x <-lsp-find-all-references => none | expected 1 (below)
::x

Drew Verlee19:12:34

With something this new (lsp) i'm not sure if the it's a missing feature, or the idea is a bad one? (maybe only symbols and not keywords are considered.. refs)?

ericdallo19:12:29

I can find those references for ::x

Drew Verlee19:12:45

i'm currently on spacemacs. How would i debug this? Whats specific to spacemacs that would change the behavior?

Drew Verlee19:12:09

i'm flippying around editors a lot right now to see whats working for me or not 🙂

Drew Verlee19:12:37

everything requires some fiddling.

ericdallo19:12:53

So, I suggest use the function of lsp-mode, as on spaceemacs or doom-emacs they should behave the same

ericdallo19:12:56

lsp-find-references

Drew Verlee19:12:10

lsp-mode was enabled so same result

ericdallo19:12:03

you mentioned above you were using lsp-find-all-references I don't know if that is something specific from spaceemacs, but I suggest using lsp-find-references

Drew Verlee19:12:03

I mispoke i was using the fn you suggest

ericdallo19:12:40

Alright, so this command, lsp-find-references works for other things? like find function refences and etc?

Drew Verlee19:12:19

putting my lsp info here for clean up

clojure-lsp 2021.12.01-12.28.16
clj-kondo 2021.10.20-SNAPSHOT

LSP :: lsp-mode 20211201.1200, Emacs 27.2,

Drew Verlee19:12:01

> Alright, so this command, `lsp-find-references` works for other things? like find function refences and etc?

Drew Verlee19:12:03

correct, most of the time.

ericdallo19:12:34

that's odd, it should work for the code:

(ns foo)

::bar
::bar
:foo/bar
find references on any of these keywords should work

Drew Verlee19:12:19

So i need to go look at how spacames and doom are setup then, as thats the best way i have to describe the difference.

ericdallo19:12:36

yeah, that's odd, I use doom though

ericdallo19:12:43

but never saw a issue like that

Drew Verlee19:12:46

FWIW here is my output lsp-doctor

Checking for Native JSON support: OK
Check emacs supports `read-process-output-max': OK
Check `read-process-output-max' default has been changed from 4k: OK
Byte compiled against Native JSON (recompile lsp-mode if failing when Native JSON available): OK
`gc-cons-threshold' increased?: OK
Using gccemacs with emacs lisp native compilation (): NOT AVAILABLE (OPTIONAL)

ericdallo19:12:08

yeah I don't think any of those are related with this issue :/

ericdallo19:12:30

maybe you can get client<->server logs

ericdallo19:12:36

this could help understand the issu

ericdallo19:12:12

try to get the log from textDocument/references

Drew Verlee19:12:05

[Trace - 01:22:12 PM] Received response 'textDocument/references - (232)' in 2ms.
Result: []


[Trace - 01:22:12 PM] Sending request 'textDocument/codeAction - (233)'.
Params: {
  "textDocument": {
    "uri": "file:///home/drewverlee/Personal/toy/src/main/toy/m1.cljs"
  },
  "range": {
    "start": {
      "line": 2,
      "character": 3
    },
    "end": {
      "line": 2,
      "character": 3
    }
  },
  "context": {
    "diagnostics": []
  }
}

Drew Verlee19:12:22

is the start and end wrong?

ericdallo19:12:44

could you send the code + the logs from the request sent, not only the response?

Drew Verlee19:12:10

sure it's hard to tell when it stops and starts ill try to clear it

ericdallo19:12:12

Note: the request you send was about codeactions not referenes

Drew Verlee19:12:41

did a full restart on emacs then lsp on, then lsp-find-references

[Trace - 01:26:44 PM] Sending request 'textDocument/codeAction - (24)'.
Params: {
  "textDocument": {
    "uri": "file:///home/drewverlee/Personal/toy/src/main/toy/m1.cljs"
  },
  "range": {
    "start": {
      "line": 2,
      "character": 3
    },
    "end": {
      "line": 2,
      "character": 3
    }
  },
  "context": {
    "diagnostics": []
  }
}


[Trace - 01:26:44 PM] Sending request 'textDocument/documentHighlight - (25)'.
Params: {
  "textDocument": {
    "uri": "file:///home/drewverlee/Personal/toy/src/main/toy/m1.cljs"
  },
  "position": {
    "line": 2,
    "character": 3
  }
}


[Trace - 01:26:44 PM] Received response 'textDocument/codeAction - (24)' in 30ms.
Result: [
  {
    "data": {
      "character": 3,
      "line": 2,
      "uri": "file:///home/drewverlee/Personal/toy/src/main/toy/m1.cljs",
      "id": "clean-ns"
    },
    "kind": "source.organizeImports",
    "title": "Clean namespace"
  }
]


[Trace - 01:26:44 PM] Received response 'textDocument/documentHighlight - (25)' in 30ms.
Result: []


[Trace - 01:26:55 PM] Sending request 'textDocument/codeAction - (26)'.
Params: {
  "textDocument": {
    "uri": "file:///home/drewverlee/Personal/toy/src/main/toy/m1.cljs"
  },
  "range": {
    "start": {
      "line": 2,
      "character": 4
    },
    "end": {
      "line": 2,
      "character": 5
    }
  },
  "context": {
    "diagnostics": []
  }
}


[Trace - 01:26:55 PM] Sending request 'textDocument/documentHighlight - (27)'.
Params: {
  "textDocument": {
    "uri": "file:///home/drewverlee/Personal/toy/src/main/toy/m1.cljs"
  },
  "position": {
    "line": 2,
    "character": 4
  }
}


[Trace - 01:26:55 PM] Received response 'textDocument/codeAction - (26)' in 31ms.
Result: [
  {
    "data": {
      "character": 4,
      "line": 2,
      "uri": "file:///home/drewverlee/Personal/toy/src/main/toy/m1.cljs",
      "id": "clean-ns"
    },
    "kind": "source.organizeImports",
    "title": "Clean namespace"
  }
]


[Trace - 01:26:55 PM] Received response 'textDocument/documentHighlight - (27)' in 31ms.
Result: []


[Trace - 01:26:57 PM] Sending request 'textDocument/references - (28)'.
Params: {
  "textDocument": {
    "uri": "file:///home/drewverlee/Personal/toy/src/main/toy/m1.cljs"
  },
  "position": {
    "line": 2,
    "character": 4
  },
  "context": {
    "includeDeclaration": false
  }
}


[Trace - 01:26:57 PM] Received response 'textDocument/references - (28)' in 5ms.
Result: []


[Trace - 01:26:58 PM] Sending request 'textDocument/codeAction - (29)'.
Params: {
  "textDocument": {
    "uri": "file:///home/drewverlee/Personal/toy/src/main/toy/m1.cljs"
  },
  "range": {
    "start": {
      "line": 2,
      "character": 4
    },
    "end": {
      "line": 2,
      "character": 5
    }
  },
  "context": {
    "diagnostics": []
  }
}


[Trace - 01:26:58 PM] Sending request 'textDocument/documentHighlight - (30)'.
Params: {
  "textDocument": {
    "uri": "file:///home/drewverlee/Personal/toy/src/main/toy/m1.cljs"
  },
  "position": {
    "line": 2,
    "character": 4
  }
}


[Trace - 01:26:58 PM] Received response 'textDocument/codeAction - (29)' in 29ms.
Result: [
  {
    "data": {
      "character": 4,
      "line": 2,
      "uri": "file:///home/drewverlee/Personal/toy/src/main/toy/m1.cljs",
      "id": "clean-ns"
    },
    "kind": "source.organizeImports",
    "title": "Clean namespace"
  }
]


[Trace - 01:26:58 PM] Received response 'textDocument/documentHighlight - (30)' in 29ms.
Result: []

Drew Verlee19:12:31

would have sent less, no idea what to edit out

ericdallo19:12:06

There is something really weird with your lsp, even code actions are returning only clean ns instead of a lot of other code actions

ericdallo19:12:30

could you paste the output of lsp-clojure-server-info ?

Drew Verlee19:12:29

LSP :: {:final-settings
 {:source-aliases #{:test :dev},
  :uri-format
  {:upper-case-drive-letter? false, :encode-colons-in-path? false},
  :cljfmt-config-path ".cljfmt.edn",
  :document-formatting? true,
  :source-paths
  ["/home/drewverlee/Personal/src" "/home/drewverlee/Personal/test"],
  :text-document-sync-kind nil,
  :project-specs
  ({:project-path "project.clj", :classpath-cmd ["lein" "classpath"]}
   {:project-path "deps.edn",
    :classpath-cmd ["clojure" "-A:dev:test" "-Spath"]}
   {:project-path "build.boot",
    :classpath-cmd ["boot" "show" "--fake-classpath"]}
   {:project-path "shadow-cljs.edn",
    :classpath-cmd ["npx" "shadow-cljs" "classpath"]}
   {:project-path "bb.edn",
    :classpath-cmd ["bb" "print-deps" "--format" "classpath"]}),
  :dependency-scheme "jar",
  :show-docs-arity-on-same-line? true,
  :document-range-formatting? true,
  :cljfmt {:indents {}}},
 :client-settings
 {:source-aliases nil,
  :cljfmt-config-path ".cljfmt.edn",
  :document-formatting? true,
  :source-paths nil,
  :text-document-sync-kind nil,
  :project-specs nil,
  :dependency-scheme "jar",
  :show-docs-arity-on-same-line? true,
  :document-range-formatting? true,
  :cljfmt {:indents {}}},
 :project-root-uri "file:///home/drewverlee/Personal",
 :port "NREPL only available on :debug profile (`make debug-bin`)",
 :project-settings {},
 :server-version "2021.12.01-12.28.16",
 :clj-kondo-version "2021.10.20-SNAPSHOT",
 :log-path "/tmp/clojure-lsp.127230218534107860.out",
 :classpath-settings nil}

ericdallo19:12:36

Could you get clojure-lsp server log and check if there is anything incorrect there like exceptions?

Drew Verlee19:12:42

I would have expected source path to be /personal/toy/.. something /personal is a directory back from the cljs project root

ericdallo19:12:25

Make sure you imported the correct project root with lsp-mode

ericdallo19:12:46

Try lsp-workspace-folders-remove to remove any wrong workspace

ericdallo19:12:54

And then lsp again

Drew Verlee19:12:39

If i change the workspace via workspace-add, to the path i suggested then it finds both keywords (from example earlier) as references. awesome. So i think something is intalizing the lsp folder wrong. Or it makes some assumption i dont

Drew Verlee19:12:08

like, its picking a directory back then i wanted and thats probably loading it more then i want or it can handle? idk.

Drew Verlee19:12:25

to be clear, something auto starts LSP for me when i went into the folder. It picked one level back in /personal (from my example) not /personal/toy which seems to work.

ericdallo19:12:14

Good, you need to remove the wrong one

ericdallo19:12:21

With the command I mentioned

ericdallo19:12:44

You chose the wrong project root probably some time ago the first time you opened the project

ericdallo19:12:51

It's a common LSP-mode issue

ericdallo19:12:06

You can find more details on it's documentation page I think

Drew Verlee19:12:37

thats what i mean, i just hit enter when it said "do you want to add workspace" I wouldn't assumed it knew or it would have asked me in a more... direct way.

Drew Verlee19:12:47

it was very confident lol

Drew Verlee19:12:03

but i have to test it. maybe i told it wrong at one point

Drew Verlee19:12:47

it "feels" like i was able to reproduce the above issue. If i make the root workspace to far back it has trouble finding refs. In this other case, the root folder is a company wide one so finding qualified keys across it is useful.

Drew Verlee19:12:11

But obviously there is a limit as to how far we can search!

ericdallo21:12:59

Yeah, I heavily recommend to use the root of the project that has the deps.edn or project.clj as some clojure-lsp features may not work if using an incorrect root

Drew Verlee04:12:21

Does it care if there are multiple deps? Thats a very common and useful thing to have is cross project shared keywords.

ericdallo13:12:09

If it's a mono repo, it may work, but if there are not related projects nope

Drew Verlee14:12:32

great, thats what i would have expected.

Drew Verlee19:12:53

more to the point it would be great if you could find all the keywords noramlized between fully qualified and aliased.

:toy.m1/x <-lsp-find-all-references => none | expected 1 (below)
::x

ericdallo19:12:21

This also already works for me

Drew Verlee19:12:55

K. Then like i said in my othe rcomment, its a spacemacs (or my config setup)

Drew Verlee19:12:59

clojure-lsp 2021.12.01-12.28.16 clj-kondo 2021.10.20-SNAPSHOT

ericdallo19:12:18

It's updated

ericdallo19:12:31

please keep the discussion in one thread if possible

Drew Verlee19:12:49

Sure thing. For some reason i thought you would want the other lol!

👍 1
slipset19:12:26

Don’t know if it’s mentioned (or done) but it would be really nice to have some way of jumping to implementations of both protocol fns and multimethods:

(defprotocol IFoo
   (foo [bar])) ;; <- click on this and get a list of places which have an implementation of `foo` for `IFoo`

;; also
(foo bar) <- click on this and get a list of possible impls, not only go to the protocol def

😍 2
ericdallo19:12:25

yeah, This is something I thought about implementing but it was not as priority as other issues, but it makes sense I think

ericdallo19:12:39

please open an issue

borkdude21:12:43

Not sure if clj-kondo provides all the analysis necessary for this, I'm pretty sure it doesn't.

borkdude21:12:50

But we can of course improve that

borkdude21:12:23

I basically winged extend-type, extend-protocol etc since the start of clj-kondo until a few days ago

borkdude21:12:58

But those expand currently not into something which let you trace this back. It's been on my mind as well, but will take more time

slipset21:12:50

What? I thought your thing was deliver things before they were actually thought of?

ericdallo21:12:39

Hum, good to know @U04V15CAJ I was not sure as well but I was about to take a look

borkdude21:12:05

@UKFSJSM38 feel free to take a look

borkdude21:12:12

but be warned!

ericdallo21:12:55

If I find any thing to be improved on kondo, I start with a issue so we can debug it better

Drew Verlee21:12:19

my lsp-session is all red dots in the tree (see pic) i would expect it to be different colorsl like here https://emacs-lsp.github.io/lsp-mode/page/troubleshooting/#log-client-server-json. I also would expect those colors to mean their typically counterparts. Like red is a problem. If so, what, what problem?

ericdallo21:12:57

I don't remember exactly what the colors mean, I can check it later ( not on PC right now)

Drew Verlee21:12:33

brb, and thanks.