Fork me on GitHub
#cider
<
2019-08-05
>
richiardiandrea06:08:44

Just a little note here - at the moment orchard does not run on node either. I was planning the port but, for instance, got rid of the cljc conversion in the info PR because it was too messy. Will do that in another PR. But that is just info -> so anything that runs on JVM and can analyze cljs code is a good candidate for the orchard for pez's use case

bozhidar06:08:20

Yeah, that’s true. In general what we need right now is to agree on the exact strategy for this analysis, though. E.g. if someone can figure out how to get more info out of the runtime analysis in the xref ns and port this also to ClojureScript perhaps we can still avoid having to keep track of a project’s AST.

👍 1
bozhidar06:08:08

Generally if we go down with generating the AST approach externally we need to also figure out some criteria for keeping it up to date - e.g. monitor for file-system changes and regen ASTs on those or something along those lines. I guess we can have a simple daemon-type of service that just handles this, but it doesn’t feel like a great fit with REPL-driven development, as in essence it would completely decoupled from the REPL state.

👍 1
pez06:08:30

For the record. Calva uses nREPL already so solutions that rely on the JVM are still potentially good for Calva if we go via nREPL. It might still make more sense to use a cljs library for things like static analyze, but it's not the only option. Pinging in @slack1038 here who is the one who have started to investigate how clj-refactor can bring value to Calva users.

bozhidar06:08:35

Well, I guessing we can certainly have a Clojure parser that parses ClojureScript code. We definitely want to avoid evaluation of the code anyways.

kstehn06:08:00

Just to clarify not clj-refactor but refactor-nrepl 😄 clj-refactor is the emacs plugin but i try to use it as insperation what to add to calva but currently stuck with the find-symbol what was here already discussed

pez06:08:04

Oh, yes, I am confusing things. s/clj-refactor/refactor-nrepl on about everything I have said here. 😃

bozhidar07:08:48

Don’t worry - I always manage to figure out what something is actually referring to.

pez07:08:54

Aren't you a programmer geek and supposed to have diagnoses preventing you from that?

bozhidar07:08:33

> I guess we can have a simple daemon-type of service that just handles this, but it doesn’t feel like a great fit with REPL-driven development, as in essence it would completely decoupled from the REPL state.

bozhidar07:08:47

Also known as LSP. 😄

bozhidar07:08:57

Just thought I should mention this here as well.

bozhidar07:08:14

Or something based on ctags (for instance).

kstehn07:08:45

we started to look into lsp but we didnt want to have to tell the user to first install something diffrent like the clojure-lsp and with the documantion, at least for me, is it not clear how to actualy use it

dpsutton12:08:57

Open an issue. The maintainer is quite friendly

pez07:08:58

> it would completely decoupled from the REPL state For situations when you have evaluated something that is not yet saved to disk (or even hidden inside (comment) and such)?

pez07:08:54

I mean, I see that it always would be completely decoupled, but wondered when you see it matters (most).

pez07:08:12

> not clear how to actualy use it For Calva it would be something like just register it, I think, and features would just magically appear.

benedek07:08:40

#trin i think is a good candidate for this -- only it is not there yet obviously. it can be easily adapted to rewrite-cljc when @lee releases it. i can only restart working on it in anger in September tho

bozhidar08:08:25

> and with the documantion, at least for me, is it not clear how to actualy use it

bozhidar08:08:30

@slack1038 Yeah, I understand what you mean. With clojure-lsp you need to download the binary, put it somewhere on your classpath and setup properly your editor to run it when it needed. I have no idea how LSP servers deal with multiple projects and how the editors know when to start/restart/stop those.

kstehn08:08:15

okay thanks 🙂

benedek08:08:03

i guess the lsp client takes care of that really

benedek08:08:42

i use it in emacs in parallel with cider nowadays. it kicks in when i open a source file in a project. it creates a directory for caches and config files in the project root directory

bozhidar08:08:19

Is it one server per project or one server for all the projects?

benedek08:08:48

one for all

dominicm08:08:26

And all for one

benedek08:08:17

cache per project

benedek08:08:27

when I open a source file in a new project it does a big analysis and caches the results -- you can opt out or postpone this

benedek08:08:16

suppose this cache is then kept up-to-date but i have not looked into this particular part

pez08:08:29

Which reminds me, refactor-nrepl has an op for warming up the AST cache. Is this cache kept up-to-date? If anyone knows w/o having to do my research work for me. 😄 (When @slack1038 and I tried it, it seemed like the cache was kept updated.)

benedek08:08:14

I think it looks at file last modified dates but i may be lying. but it is deffo kept up-to-date

metal 2
dominicm08:08:34

Warm-cache is sent in the background when cider first connects so that the first refactor operation you do doesn't take forever.

pez08:08:11

That's what @slack1038 did in his Calva branch as well.

bozhidar08:08:14

We’ve agreed with @pez to form a “Task Force” to tackle this and other common problems. I’ll form some channel about this soon and invite everyone interested in the work to join in (and the calls we’re about to have). I think it’s time we started working on the Clojure tooling foundations in a more structured manner and that’s going to be the first step. 🙂

richiardiandrea22:08:18

Count me in (after August)

metal 1
bozhidar08:08:36

@dominicm @benedek I’m volunteering both of you for the task force. 😉

benedek08:08:42

+1 here boss :)

bozhidar09:08:53

😄 😄 😄

andrea.crotti16:08:34

is it actually possible to send a form directly to cider and see its evaluation?

andrea.crotti16:08:47

I can't find the command in the docs or checking all the cider functions

andrea.crotti16:08:00

but I think I've seen someone doing it at heartofclojure

andrea.crotti16:08:08

(i could probably write the function myself if it doesn't exist)

andrea.crotti16:08:35

actually sending the form to the right cider repl and switching would be enough, no need to evaluate as well automatically

dmaiocchi16:08:41

I use C-X C-E for evaluating things

dmaiocchi16:08:02

and for sending it to repl there is a complementary cmd

andrea.crotti16:08:02

ah I found it now

andrea.crotti16:08:12

it was cider-insert.*

andrea.crotti16:08:16

and all the related functions, cool I can't believe I never used it 😄

dmaiocchi16:08:20

yep I had also same thought the 1st time I have discovered it 😁

dmaiocchi16:08:47

during the conf btw, I was about to ask people why the evaluate function by function

dmaiocchi16:08:18

normally you can evaluate the whole buffer with C-c C-k

dmaiocchi16:08:34

so you don't have to evaluate function by function (but everyone has is own personal repl workflow) 😁

dmaiocchi16:08:13

anyways for me the basic workflow current documentation is pretty well written

dmaiocchi16:08:34

one can have really the basic things there covered without going through the whole doc

dpsutton16:08:57

(setq cider-invert-insert-eval-p t)
    (setq cider-switch-to-repl-after-insert-p nil)
    (setq cider-switch-to-repl-on-insert-p nil)
helpful for the insert commands

bozhidar16:08:56

@darioszr The basic workflow is a bit too basic right now, but my idea for this section is to teach people how to use CIDER is something like 3-5 minutes. 10-15 essential commands and off to productivity. 🙂

dpsutton16:08:30

(setq clojure-toplevel-inside-comment-form t) for working inside of comment blocks

👍 1
pez16:08:57

invert-insert-eval?

dpsutton16:08:23

the default is to not eval. I prefer to eval automatically

dpsutton16:08:55

"Whether to invert the behavior of evaling.
Default behavior when inserting is to NOT eval the form and only eval with
a prefix.  This allows to invert this so that default behavior is to insert
and eval and the prefix is required to prevent evaluation."

bozhidar16:08:58

Yeah, the original idea was that you’d be sending the whole forms only if you needed to edit them before evaluating them. Turned out some people liked keeping tracked of things they eval in the REPL.

dmaiocchi16:08:42

@bozhidar imho as basic workflow looks already a good basic thing

dmaiocchi16:08:20

I mean the essential stuff are already there 😁 as long one can evalute buffer and expression, imho that's the things one need as basic

dmaiocchi16:08:53

we could then just call intermediate workflow and ninja workflow then..

dmaiocchi16:08:38

as perhaps good hint we could add the command to switch to namespace perhaps in basic? ( i use it quite a lot

dmaiocchi16:08:41

but i use now like (in-ns 'newns2) for swtiching namespaces

dmaiocchi16:08:29

before i was using cider for that, but I tend to forget all the keystroke combinations 😁 so in-ns for that was more in my brain.. 😁

dmaiocchi17:08:47

or form your pov what would be missing in the base workflow?

alexeiz17:08:46

Hi. I have a problem with repl in this setup: emcs/cider/shadow-cljs. I start it with cider-jack-in-cljs, then choose shadow as the repl type, then 'select shadow-cljs build' - app, then 'visit... in browser' - n, and it drops me into cljs.user> prompt (even though I have :nrepl {:init-ns my.ns} in shadow-cljs.edn.

alexeiz17:08:32

is this the right way to do it? Am I missing anything?

alexeiz17:08:27

if I try to call anything from my.ns, like (my.ns/main!), I get error 'no application has connected to the repl server. make sure your js environment has loaded your compiled clojurescript code.'

dpsutton17:08:18

do you have a browser open and your app successfully loaded?

alexeiz17:08:40

my app is :target :node-script

alexeiz17:08:58

it's not a browser app

dpsutton17:08:52

is :node-script correct?

alexeiz17:08:47

I think so. I'm able to compile it with 'shadow-cljs compile app' and it produces target/main.js which I'm able to run with nodejs

dpsutton17:08:49

ah nevermind. that's correct

dpsutton17:08:57

is it public?

alexeiz17:08:43

you mean, is code public? no, but I can post shadow-cljs.edn, it's the only thing that's needed, right?

dpsutton17:08:13

{:source-paths ["src"]
 :dependencies [[reagent "0.8.1"]
                [cljs-styled-components "0.1.5"]
                [org.clojure/core.async "0.4.490"]]

 :builds {:app {:target     :browser
                :output-dir "target/js"
                :asset-path "js/"
                :modules    {:main {:init-fn asg.main/main!}}
                :devtools {:http-root "target"
                           :http-port 8080}}}}
example of a shadow-cljs.edn for me that works. I just use cider-jack-in-cljs. CIDER manages nrepl and piggieback and all the goodies

alexeiz17:08:13

here it is: https://pastebin.com/JpmhZpNg it's pretty barebone

dpsutton17:08:11

> You do not usually need to set :optimizations since the :target already sets it to an appropriate level.

dpsutton17:08:18

try it without optimizations

alexeiz17:08:56

I removed all :compile-options. The behavior is the same.

dpsutton17:08:21

hmm. i get the same behavior. I wonder how shadow exposes the node cljs environment. perhaps piggieback isn't seeing it?

dpsutton17:08:31

or actually, piggieback might not be involved. been a while since i've worked inside of shadow

dpsutton17:08:40

@thheller might have some thoughts but i have to run to lunch

alexeiz17:08:00

I followed https://shadow-cljs.github.io/docs/UsersGuide.html#_launch_the_clojurescript_repl and got to the point of [:selected :app] cljs.repl> prompt with no errors, but then I'm not able to call anything, but get 'no application has connected to the repl' error

alexeiz17:08:01

I feel I'm missing something simple

pez17:08:12

Have you started the app?

alexeiz17:08:48

no, it's a node-script app, not a browser app

dpsutton17:08:04

(I'm missing the same simple thing if so :)

pez17:08:26

It still needs to be started to connect to the repl, right? Can you connect to a :node-repl?

alexeiz17:08:41

I'm not sure how to connect to a :node-repl

alexeiz18:08:39

any other ideas?

pez18:08:37

Try asking in #shadow-cljs , this seems like there is something special with the :node-script target that we are missing.

thheller19:08:28

for :node-script you need to manually launch the actual node process. node-repl is a special internal "build" that has no direct configuration but handles launching the node process internally. so from the command line you just run shadow-cljs node-repl and that gives you the REPL directly. you can "select" that REPL in CLJS by running (shadow.cljs.devtools.api/repl :node-repl) or start it via (shadow.cljs.devtools.api/node-repl)

thheller19:08:46

I' unsure how cider handles the build selection parts though

alexeiz20:08:50

@thheller I sort of got it working with (shadow.cljs.devtools.api/node-repl) but it's a pita. It should be easier than this