Fork me on GitHub
#lsp
<
2023-02-10
>
Jakub Holý (HolyJak)12:02:57

Is displaying call hierarchy (i.e. the tree of functions that call a function) something LSP could/should do?

2
borkdude12:02:49

@U0522TWDA This is already a feature of clojure-lsp. What editor are you using?

😻 2
ericdallo12:02:36

If using lsp-mode lsp-treemacs-call-hierarchy , I think it works in vscode as well. https://clojure-lsp.io/features/#call-hierarchy

ericdallo12:02:07

lsp-treemacs-call-hierarchy for incoming call hierarchy C-u lsp-treemacs-call-hierarchy for outgoing

til 4
Jakub Holý (HolyJak)12:02:05

VS Code. I see Code commands include “Calls: Show call hierarchy” but that renders no results, and possibly has nothing to do with LSP. @U0ETXRFEW?

ericdallo12:02:34

it does seem to work for me calling that command

Jakub Holý (HolyJak)12:02:22

Ah, it does now. I guess LSP was not ready yet. Thansk a lot!

👍 4
Jakub Holý (HolyJak)12:02:34

Great work! LSP is awesome!

gratitude 2
Jakub Holý (HolyJak)12:02:09

Hm, is there some simple way to exclude calls from test files / path?

pez12:02:18

For the record: The Show Call Hierarchy command as such is built-in to VS Code. Needs to be implemented by the language extension. clojure-lsp implements it in the case of Calva.

👍 2
ericdallo12:02:49

I think that should be done for each client @U0522TWDA, not sure if vscode supports that but I can see how convenient it is, I used that in Eclipse a lot in the past

pez12:02:23

I don't think VS Code enables a way to excludes calls from certain files. Might be something Calva can be made to do, idk.

👍 4
Noah Bogart14:02:54

go to definition doesn't seem to work if a namespace uses load. Is this on the roadmap? Should I open a github issue about it?

borkdude14:02:05

Do you have an example?

Noah Bogart14:02:45

record? is in clojure.core, but the definition can't be found cuz it's implemented in core_deftype.clj: https://github.com/clojure/clojure/blob/clojure-1.11.1/src/clj/clojure/core_deftype.clj#L406

Noah Bogart14:02:42

2023-02-10T14:27:17.931Z  DEBUG [clojure-lsp.server:55] - [Trace - 2023-02-10T14:27:17.931Z] Received request 'textDocument/definition - (95)'
Params: {
  "text-document" : {
    "uri" : "file:///home/noah/personal/spat/src/noahtheduke/core_extensions.clj"
  },
  "position" : {
    "line" : 15,
    "character" : 4
  }
}



2023-02-10T14:27:17.932Z  INFO [clojure-lsp.handlers:246] - :definition 0ms
2023-02-10T14:27:17.933Z  DEBUG [clojure-lsp.server:55] - [Trace - 2023-02-10T14:27:17.932Z] Sending response 'textDocument/definition - (95)'. Request took 1ms.
Result: null

borkdude14:02:44

I've only seen load used in clojure implementation libraries. Adding support for that seems rather niche

Noah Bogart14:02:04

🤷 that's why i'm asking

Noah Bogart14:02:15

a long time ago, we used load in a project that put all of a game's engine logic into a single namespace but split across many many files. was a pain in the butt to work with lol

snoe16:02:02

I wonder if handling in-ns might be another route, IIRC we pass core_deftype.clj to kondo now.

borkdude16:02:32

clj-kondo has support for in-ns AFAIK

borkdude16:02:03

but maybe it's not good enough :)