Fork me on GitHub
#calva
<
2021-04-10
>
pez07:04:06

Dear Calva-friends: v2.0.186 just out https://github.com/BetterThanTomorrow/calva/releases/tag/v2.0.186, see also #releases for an extract of the last two weeks of changes.

calva 9
xavi11:04:57

Hello! How to get a ClojureScript REPL in Calva without using Figwheel or shadow-cljs?

xavi11:04:03

I want to connect it to the hello-world project of ClojureScript's "Quick Start" guide (https://clojurescript.org/guides/quick-start).

xavi11:04:17

I can't figure out how to get it working.

xavi11:04:25

(In another project I have Calva with Figwheel working fine, but I would like to have this hello-world project with the minimum and simplest setup.)

pez11:04:44

@xavi: This is a stupid omission in the default jack-in/connect sequences that should be fixed. Please feel invited to add an issue about it. However, all is not lost, you can define this as a custom sequence. It would look like so in .vscode/settings.json:

{
    "calva.replConnectSequences": [
        {
            "projectType": "deps.edn",
            "name": "plain cljs repl",
            "cljsType": {
                "dependsOn": "User provided",
                "connectCode": "(do (require 'cljs.repl.node) (cider.piggieback/cljs-repl (cljs.repl.node/repl-env)))"
            }
        }
    ]
}
Then jack in and select plain cljs repl as the Project type.

xavi12:04:17

Great, thank you! I got the cljs꞉cljs.user꞉> prompt and it works.

xavi12:04:50

I have another problem now, though it doesn't seem related to Calva...

pez12:04:08

Ask it anyway 😃

xavi12:04:31

That connect sequence doesn't open a web server, so I'm trying to start one from the command line using

clj -m cljs.main --serve
and i get...

xavi12:04:59

WARNING: When invoking clojure.main, use -M
Serving HTTP on localhost port 9000
Exception in thread "Thread-1" java.lang.NullPointerException: Cannot invoke "java.util.concurrent.Future.get()" because "fut" is null
...
Exception in thread "Thread-2" java.lang.NullPointerException: Cannot invoke "java.util.concurrent.Future.get()" because "fut" is null

xavi12:04:46

Any idea ? (this invocation also appears in https://clojurescript.org/guides/quick-start )

pez12:04:04

The connect sequence doesn’t connect a browser repl either. But that is a later problem for when you have gotten the cljs app running in the browser. I’ll see if I have any idea….

pez12:04:34

Actually, it seems to be a matter of starting a browser repl. Make the settings look like so

{
    "calva.replConnectSequences": [
        {
            "projectType": "deps.edn",
            "name": "plain cljs node repl",
            "cljsType": {
                "dependsOn": "User provided",
                "connectCode": "(do (require 'cljs.repl.node) (cider.piggieback/cljs-repl (cljs.repl.node/repl-env)))"
            }
        },
        {
            "projectType": "deps.edn",
            "name": "plain cljs browser repl",
            "cljsType": {
                "dependsOn": "User provided",
                "connectCode": "(do (require 'cljs.repl.browser) (cider.piggieback/cljs-repl (cljs.repl.browser/repl-env)))"
            }
        }
    ]
}
Then jack in again, choosing the browser project type.

xavi12:04:45

Yes! That works for me... and I can get the cljs app running in the browser using "Calva: Load current file and dependencies" with the hello_world/core.cljs file

pez12:04:04

Awesome.

xavi12:04:09

In a full-stack clj/cljs app with its own web server, this setup would work too? Anyway, i'll try later today. I'll also open an issue to have this "plain cljs browser repl" connect sequence built-in

pez13:04:16

Yes, full stack should just work. There is both a Clojure and ClojureScript REPL there. If you create a .clj file it will be using the Clojure REPL. And if you create a .cljc file you can toggle which REPL it should be connected to. There’s even a button in the status bar for this.

xavi19:04:56

Thank you!

pez20:04:48

Oh, thanks for this issue. And super that you found that old issue. I pasted the node repl config there and closed it. (Since the reporter hasn’t been heard from in a while, we can’t really hope for a confirmation.)

Stuart13:04:08

Anyone know of any pretty-clojure-symbols for VS Code, like pretty-symbol for cursive?

alefeans16:04:55

Nowadays, i'm only using this substitution:

"prettifySymbolsMode.substitutions": [
        {
            "language": "clojure",
            "prettifySymbolsMode.renderOn": "none",
            "prettifySymbolsMode.revealOn": "none",
            "prettifySymbolsMode.prettyCursor": "none",
            "prettifySymbolsMode.adjustCursorMovement": true,
            "substitutions": [
                {
                    "ugly": "fn",
                    "pretty": "λ",
                    "pre": "\\(",
                    "post": "\\s\\[",
                    "style": {
                        "color": "#B877DBE6"
                    }
                }
            ]
        }
    ]

Stuart16:04:19

thanks, i never found that one when I was looking!

alefeans16:04:03

U're welcome ! It's very easy to use 🙂

pez13:04:41

What does pretty-symbol do?

Stuart13:04:39

it replaces some character combinations with single character, e.g.

Stuart13:04:56

that gate symbol is let, the f is defn

Stuart13:04:33

anonymouse functions look like this

Stuart13:04:18

fira code does some of it for me, but its general font stuff not clojure specific obviously

pez13:04:32

Haha, how awful. 😃 There are fonts that do this. Like Tonsky’s FIRA Code. However, last time I checked it didn’t have a lambda symbol, and Tonsky didn’t plan to add it, because it is not wide enough.

Stuart13:04:03

I find things that reduce the amnount of code I have to read makes understanding stuff easier for me

Stuart13:04:26

I think things like defn / let / fn / set add to the noise

pez13:04:36

Yeah, that’s the rationale behind FIRA Code as well. I tried it. Got super confused and dropped it. 😃

pez13:04:24

Let’s see if someone else knows what options there are for this.

👍 3
Stuart13:04:59

@pez, i've switched to calva from cursive / ideaj and won't be going back! Calva really is wonderful. IdeaJ would crash and hang a lot, would struggle if a clojure file got over 1000 lines or so. Support for CLJS was annoying at times. Calva is just great, it all just works and getting repl evals to show inline in the editor, fantastic! Really great job dude, i love it

❤️ 9
calva 9
pez13:04:47

Thanks! Please consider filing a review. Link in the channel topic.

Janne Sauvala14:04:38

Hello 👋:skin-tone-2: what is the correct way to configure clj-kondo/clojure-lsp linter with Calva? The clj-kondo and clojure-lsp docs differ a little bit. I want to ignore unused-public-var warning and I tried to place my config {:linters {:unused-public-var {:exclude #{prode.extension/reload}}}} under ./lsp/config.edn ./clj-kondo/config.edn but that didn’t seem to help

borkdude14:04:38

Damn, you are fast :)

😅 3
ericdallo14:04:02

@janne.sauvala the unused-public-var is the only linter implmenented on clojure-lsp side, the rest is from clj-kondo, so you just need to change your .lsp/config.edn if you want to change its behaviour

Janne Sauvala14:04:12

Thanks! Are you both just chilling here waiting for newbies to ask questions? 😄

ericdallo14:04:55

hahaha I have configured my slack to warn about any metion to clojure-lsp or lsp 😄

ericdallo14:04:15

probably borkdude did the same for clj-kondo haha

borkdude14:04:24

you got me

🎯 3
Janne Sauvala14:04:46

Great, this feels like some paid support service 🙂

3
borkdude14:04:19

It makes you wonder, if clj-kondo is free and our support is free, you must be paying with something else...

😂 6
pez14:04:22

And you pay with love. 😃

borkdude14:04:45

Ah, that must be it then ;)

Janne Sauvala14:04:02

okay I have my config in the .lsp/config.edn but I still see the linter warning… Does Calva automagically pick the config up or do I need to do something?

pez14:04:06

John Lennon was right!

pez14:04:32

I think you need to reload the VS Code window.

☝️ 3
ericdallo14:04:08

@janne.sauvala You need to restart clojure-lsp, closing/re-opening vscode will do that, not sure there is a command for that

pez14:04:47

So, you don’t need to restart vscode, just FYI.

👍 3
Janne Sauvala14:04:55

right! I reloaded the window and now the warning went away like it should 🙂

🚀 3
Janne Sauvala14:04:33

thanks all 3 of you!

ericdallo14:04:43

I have an idea to remove that need to restart clojure-lsp in the future :)

pez14:04:44

You can pay with an issue on Calva to support reloading of clojure-lsp w/o reloading the vscode window. 😃

3
pez14:04:35

Reloading clojure-lsp is quick though. It is losing your REPL session that is the too high price, imo.

👍 3
borkdude14:04:23

@janne.sauvala That linter is not a clj-kondo thing, it's implemented by LSP

pez21:04:01

Dear Calva friends. I hope the new Calva version (2.0.186) is treating you well. Now it is time to help me test a new VSIX again. It adds built in jack-in/connect sequences for plain CLJS REPLs (Browser and Node). It makes it much easier to follow the steps in the https://clojurescript.org/guides/quick-start using Calva. • VSIX: https://12811-125431277-gh.circle-artifacts.com/0/tmp/artifacts/calva-2.0.187-1114-add-vanilla-cljs-repl-sequences-3d416bdd.vsix • Issue addressed: https://github.com/BetterThanTomorrow/calva/issues/1114 • PR: https://github.com/BetterThanTomorrow/calva/pull/1115

🚀 12
pez21:04:20

Ping, @xavi, can you help test this for me?

xavi10:04:30

Successfully tested the latest one (not the linked above), which changes "plain" with "built-in"...

xavi10:04:22

(i don't like that macOS hides filename extensions... i couldn't install the .vsix at first because although i thought i changed the .zip extension to .vsix, VS Code wouldn't allow me to install it... until I realized that macOS was hiding the real extension and now I had a .vsix.zip . oh well )

pez10:04:22

Awesome. Thanks!

xavi10:04:36

np, thanks to you!