cursive

Jan Šuráň 2025-01-29T10:35:42.708549Z

Hello, in a ClojureScript REPL, Cursive can't resolve any symbols. I had this problem on some older IntelliJ version as well, upgrading didn't help. Software information: IntelliJ IDEA 2024.3.2.1 (Community Edition) Build #IC-243.23654.153, built on January 23, 2025 Runtime version: 21.0.5+8-b631.30 amd64 (JCEF 122.1.9) VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Toolkit: sun.awt.windows.WToolkit Windows 11.0 GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation Memory: 8192M Cores: 20 Registry: ide.experimental.ui=true http://llm.show.ai.promotion.window.on.start=false Non-Bundled Plugins: com.andrey4623.rainbowcsv (2.0.2) com.verilang (0.1.8) nl.rubensten.texifyidea (0.10.0) com.github.copilot (1.5.32-242) com.cursiveclojure.cursive (1.14.0-2024.3) com.firsttimeinforever.intellij.pdf.viewer.intellij-pdf-viewer (0.17.0) Kotlin: 243.23654.153-IJ

thheller 2025-01-29T16:25:14.861059Z

that is usually a sign that Cursive can't see your dependencies, or those dependencies are missing clojure/clojurescript

thheller 2025-01-29T16:25:39.352639Z

make sure to enable any given aliases in Cursive when using deps.edn with aliases

Jan Šuráň 2025-01-29T18:41:56.432709Z

Hmm, I've found the cause... It's in the clj/cljs switch on the right, for some reason, the language server doesn't switch to cljs mode after typing shadow/repl... Probably a bug? If I set the mode to cljs and then restart the REPL, the clj mode is back, but it stays that way.

Jan Šuráň 2025-01-29T18:42:54.162279Z

But the REPL works, it just doesn't resolve anything from clojurescript...

Jan Šuráň 2025-01-31T19:27:03.979329Z

@cfleming Can I get your view on this?

Roman Liutikov 2025-01-29T12:39:21.226809Z

Are there any plans for Cursive to support LSP? I'm currently looking into integrating TypeScript language server into clojure-lsp, but I find Cursive user experience superior to clojure-lsp. JS/npm integration is something that many of us been asking for a long time, I know it's complicated, maybe adding LSP client to Cursive is doable and could serve as a point of extension?

grav 2025-01-30T13:48:34.807229Z

> integrating TypeScript language server into clojure-lsp Can you elaborate @roman01la? Would it mean being able to use type information from TS classes in ClojureScript?

Roman Liutikov 2025-01-30T14:13:15.079389Z

@grav Yes, this will require a mapping layer to generate JS from a sexp under cursor + turn ns requires into js imports. Once all of that is sent to TS server it will respond with a list of completion tokens

💡 1
❤️ 1
Roman Liutikov 2025-01-30T14:14:10.114869Z

(.| js/document) -> document.|

(ns :require [react]) -> import * as react from "react"
(react/|) -> react.|

Roman Liutikov 2025-01-30T14:16:55.545329Z

type information can be also used to enrich inference in cljs code, this can be done in cljs compiler as well btw, not only in the editor

👍 1
cfleming 2025-01-30T18:37:35.257989Z

I see, you'd convert before calling LSP, interesting. I know a couple of plugin devs who are right down the LSP rabbit hole, I'll ask them for advice.

Roman Liutikov 2025-01-30T19:52:04.268179Z

Correct. This should work for simple cases like the above, but more complex code where one location references the other one could be less straightforward

(let [x js/obj]
  (.| x))
this requires parsing transforming potentially larger blocks of cljs, I’d try to infer JS only forms and skip everything else Not sure how performant it’s going to be though

cfleming 2025-01-29T20:57:23.548979Z

Yes, I know this is a pain point and I'm planning to make another round of improvements here soon. The issue with LSP is that I don't think it exposes the functionality that Cursive needs, but I can look at it again. The same is true of the built-in IntelliJ JS functionality, it all relies on having source files that look roughly like JS/TS, so it works ok for something like Coffeescript but not for ClojureScript.