Fork me on GitHub
#calva
<
2023-07-09
>
otwieracz18:07:05

Is this possible in Calva to access spec function definitions (`fdef`) in documentation tooltips?

otwieracz09:07:56

For example, I've got a function fetch-entity that fetches the item from db using jdbc. I've got s/fdef describing return value for that function Is there any way to access that return type definition using calva/clj-kondo/clojure-lsp so I can have an idea what kind of data I'll get from fetch-entity?

pez09:07:20

I think I remember someone using customHoverSnippets to this effect. Could be remembering that wrong, but maybe a slack search can tell you.

Jan19:07:51

I have a monorepo where my Clojure backend is a subdirectory of project-root (VSCode workspace root). Each time I open the workspace clojure-lsp will use the workspace root as project root and I have to switch it. The structure is like this

project-root/
├─ .lsp/
│  ├─ config.edn
├─ backend/
│  ├─ deps.edn
From what I understood from the clojure-lsp docs I could put a config.edn into .lsp as shown above to specify the project path. My config looks like this
{:project-specs [{:project-path "backend/deps.edn"}]}
This does not seem to suffice as clojure-lsp is confused an throws an error
LSP classpath lookup failed when running ``. Some features may not work properly if ignored. Error: No value supplied for key: :dir Choose an option:
I am not quite clear what I need to do here. Any guidance?

Jan19:07:54

In essence I just want to tell clojure-lsp on a workspace level which projects to activate. Clojure-lsp sees the backend project already but does not activate it by default.

ericdallo23:07:23

Nope, project-spec could work, but you need a little bit more tunning, project-spec is a way to tell: clojure-lsp, when you find a this file (project-path) run this command (classpath-cmd). I suggest you try something else first: • maybe add a deps.edn at the root in a :dev alias if that is not a problem and it's a clojure project as well with a :local-root pointing to the backend deps edn, that should be enough to work. Fun fact: clojure-lsp project itself is a mono-repo that uses this strategy, you can peek if you want. • Open the backend folder instead? • Tune project-specs, should work too

Jan08:07:12

I will try that out, thank you. To be honest I think it's quite counter intuitive from a UI/UX point of view because I am able to activate a specific project (or multiple) by just a click but am not able to save this selection somehow and instead need to fiddle around with config files and get them right.

ericdallo11:07:28

clojure-lsp has a good default for most configs, but when you have corner cases like yours where you want a subdir of a parent root, you need to tweak. TBH that is more a client issue as the client(editor) should have options to send different project roots like emacs does, but it's hard to implement that on calva

Jan13:07:23

Hmmm 'hard to implement' sounds like a challenge. Maybe I can do it myself 🙂

ericdallo15:07:36

Yeah, that would be nice, but AFAI remember, it was a vscode limitation, not something calva can workaround, but Calva maintainers will know better

otwieracz09:07:56

For example, I've got a function fetch-entity that fetches the item from db using jdbc. I've got s/fdef describing return value for that function Is there any way to access that return type definition using calva/clj-kondo/clojure-lsp so I can have an idea what kind of data I'll get from fetch-entity?