Fork me on GitHub
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?


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

😻 2

If using lsp-mode lsp-treemacs-call-hierarchy , I think it works in vscode as well.


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?


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?


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

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


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?


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:

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


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


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


clj-kondo has support for in-ns AFAIK


but maybe it's not good enough :)