Fork me on GitHub
#cider
<
2018-03-06
>
bozhidar04:03:04

> My recent pattern has been cider-jack-in (for clj), then cider-create-sibling-cljs-repl

bozhidar04:03:03

@mikerod Btw, cider-jack-in-clojurescript just start a regular Clojure REPL and then invokes cider-create-sibling-cljs-repl.

bozhidar04:03:06

The biggest problem right now is that we haven’t implemented injection of the ClojureScript deps. Unfortunately that’s a bit tricky as you can’t be certain which REPL variant the user will want to start and they have different deps.

bozhidar04:03:39

One cool idea would be to add hotload-deps from refactor-nrepl to CIDER itself - then we can just hotload on demand the cljs REPL deps.

mikerod04:03:25

Thanks @bozhidar I tried it today and it was working. Was nice to merge both steps into one for me. I guess I had enough setup to not get any issue. It does sound tricky in general. I wanted to go through https://github.com/clojure-emacs/cider/issues/2202 to see what was happening there

bozhidar04:03:59

Not much still. I mostly focused on decoupling the cljs repl from build tools and some saner error reporting.

dpsutton04:03:06

@bozhidar did you see that your cljs repl checking didn't work? the ns-find check isn't sufficient

bozhidar04:03:37

Unfortunately I managed to mess up even this - for some reason I thought find-ns works for unrequired namespaces, and took this shortcut.

dpsutton04:03:38

don't mean to harp on it if you did 🙂 but i'm surprised we haven;'t had more bug reports

bozhidar04:03:42

Yeah, yeah - I saw it.

dpsutton04:03:01

i assumed the same. i couldn't fathom why it wasn't working

bozhidar04:03:47

I guess we need to expand the ns middleware to have one ops for finding namespaces.

dpsutton04:03:17

yeah orchard has something that we can use. just need to expose it

bozhidar04:03:22

I think nrepl-refactor has something to deal with libraries directly - that might be even better. @benedek

bozhidar04:03:57

I really hate it that there’s no unified API to just check what are libs that are currently present and you always have to jump through some hoops.

dpsutton04:03:01

if cljstays fast we could probably in the future just ask for a copy of the class path

dpsutton04:03:14

yeah. i saw that we already do this in orchard already though

bozhidar04:03:01

In a way it’s exposed even now - ns-list returns all namespaces if memory serves, so all you need is to check that list.

bozhidar04:03:02

The big problem is that you still don’t know the metadata for the library - you might have added the wrong version of some library or whatever and ideally we need a way to check this.

bozhidar05:03:24

A few days about @xiongtx asked me to create some basic roadmap document for CIDER, so that collaborators can know what to focus on - here’s the first cut https://github.com/clojure-emacs/cider/blob/master/ROADMAP.md

bozhidar05:03:06

I hope some of you are going to find it useful. As you can see there’s plenty of work to go around, so we need all the help we can get. 🙂

richiardiandrea05:03:18

@bozhidar may I ask you why the choice of parseclj? I think I saw way more tests in edn.el...it is because of the different representation?

bozhidar06:03:21

Mostly because I’m worried about edn.el’s main dependency - peg.el was last updated 10 years ago and it’s officially hosted on EmacsWiki.

bozhidar14:03:50

I missed this part. It certainly wasn’t there last time I checked. 🙂

bozhidar06:03:22

That’s why CIDER never picked it up, even though it really could benefit from some Clojure parser. parseclj is too young, but I hope it can become the parser we all need. 🙂

bozhidar06:03:46

Of course, I might be wrong and peg.el might be engineered to perfection. Who knows?!? 😄

xiongtx06:03:29

> replaces usages of Elisp's read with parseclj Can you elaborate on this? Are we using Elisp's read to read clj ? If so, I'd guess that read is limited to shard data structures b/t Elisp and clj (e.g. lists). What's the advantage to using parseclj in that case?

richiardiandrea06:03:22

I think one of the most basic ways to convert lists to elisp is to read them. Inf-clojure employs the same trick yes. I have started introducing edn.el and so far it seems pretty solid. I haven't used in performance-critical things though, and the PR has not yet been merged but "it works on my machine" 😄

richiardiandrea06:03:26

edn.el or parseclj convert edn to elisp data structures. I think with a slightly different representation of edn in elisp data

bozhidar14:03:49

The main advantage of using a proper parser is that we won’t be limited to using in results things that exist in Elisp. Some APIs return suboptimal things just because that’s what we can process.

bozhidar14:03:33

Very simple example - you can’t process directly booleans, as they don’t existing in Elisp.

xiongtx06:03:18

> basic refactoring stuff (potentially related to the merger of stuff from clj-refactor.el) Is it a goal to move the entirety of clj-refactor into CIDER? Is that wise, given the large number of dependencies clj-refactor has? https://github.com/clojure-emacs/clj-refactor.el/blob/408ab1f13b8d956dd8d2c839bea5197175ef5a93/clj-refactor.el#L35-L49

bozhidar14:03:17

Just simple stuff that don’t depend on parsing the code. hotload deps depends just on dynapath, the ns cleanup doesn’t have external deps if I recall correctly.

bozhidar14:03:09

My concern with the massive deps and the complexity added by the use of the Clojure parser are the main reason this ended up being a separate library in the beginning.

stardiviner10:03:22

Does Clojure has flycheck support in Emacs?

stardiviner10:03:36

I did a search in MELPA, what about flycheck-clojure? compare this two packages.

manuel11:03:39

if you're asking me, I don't know. I only answered your question "Does Clojure has flycheck support in Emacs?" with the one I remembered. 🙂

gganley14:03:23

@bozhidar After my meeting today I’ll be working on [#2203] if you want to throw me down as an assignee.

stardiviner14:03:40

@bozhidar I got error with flycheck-clojure package (means squiggly-clojure) Here is the error:

Debugger entered--Lisp error: (wrong-number-of-arguments (4 . 4) 0)
  #f(compiled-function (buffer ex rootex sess) #<bytecode 0xc28c55d>)()
  #f(compiled-function (response) #<bytecode 0xc28c5c1>)((dict "ex" "class java.io.FileNotFoundException" "id" "201" "root-ex" "class java.io.FileNotFoundException" "session" "690bc29a-26d8-41c4-856b-64cb809d8853" "status" ("eval-error")))
  nrepl--dispatch-response((dict "ex" "class java.io.FileNotFoundException" "id" "201" "root-ex" "class java.io.FileNotFoundException" "session" "690bc29a-26d8-41c4-856b-64cb809d8853" "status" ("eval-error")))
  nrepl-client-filter(#<process nrepl-connection> "d2:ex35:class java.io.FileNotFoundException2:id3:2017:root-ex35:class java.io.FileNotFoundException7:session36:690bc29a-26d8-41c4-856b-64cb809d88536:statusl10:eval-erroreed3:err235:FileNotFoundException Could not locate squiggly_clojure/core__init.class or squiggly_clojure/core.clj on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.  clojure.lang.RT.load (RT.java:463)\n2:id3:2017:session36:690bc29a-26d8-41c4-856b-64cb809d8853ed2:id3:2017:session36:690bc29a-26d8-41c4-856b-64cb809d88536:statusl4:doneeed18:changed-namespacesde2:id3:2019:repl-type3:clj7:session36:690bc29a-26d8-41c4-856b-64cb809d88536:statusl5:stateee")

stardiviner14:03:45

And my config

gganley14:03:25

two questions, is root-ex your file and did you follow the instructions on the readme page?

stardiviner14:03:05

Yes, I followed instructions on README. And no, root-ex is not my file, my file is core.clj.

gganley14:03:36

Let me read the README lol

gganley14:03:18

I’m on my iPad so I can’t test it myself but did you try just running the sample project? https://github.com/clojure-emacs/squiggly-clojure/tree/master/sample-project

stardiviner14:03:23

I will take a try on that.

dpsutton14:03:01

its because the signature of the error handler has changed. flycheck-clojure has a dependency on cider 0.8.1 which would call the error handler like so:

(funcall (or eval-error-handler nrepl-err-handler)
                        buffer ex root-ex session)

dpsutton14:03:31

line 832 of nrep-client.el if you check out the release tag of 0.8.1 of cider

dpsutton14:03:20

and now its a thunk:

(when (member "eval-error" status)
               (funcall (or eval-error-handler nrepl-err-handler)))

dpsutton14:03:34

which is why the error is saying wrong number of arguments. you gave me 4 and I expect 0

dpsutton14:03:27

and how the default one works:

(defun cider-default-err-op-handler ()
  "Display the last exception, with middleware support."
  ;; Causes are returned as a series of messages, which we aggregate in `causes'
  (let (causes)
    (cider-nrepl-send-request
     (nconc '("op" "stacktrace")
            (when (cider--pprint-fn)
              `("pprint-fn" ,(cider--pprint-fn)))
            (when cider-stacktrace-print-length
              `("print-length" ,cider-stacktrace-print-length))
            (when cider-stacktrace-print-level
              `("print-level" ,cider-stacktrace-print-level)))
     (lambda (response)
       ;; While the return value of `cider--handle-stacktrace-response' is not
       ;; meaningful for the last message, we do not need the value of `causes'
       ;; after it has been handled, so it's fine to set it unconditionally here
       (setq causes (cider--handle-stacktrace-response response causes))))))
so now its a thunk because the handler reaches back for exception information

dpsutton14:03:12

and this comment in flycheck clojure probably explains the change:

;; If the evaluation completes without returning any value, there has
        ;; gone something wrong.  Ideally, we'd report *what* was wrong, but
        ;; `nrepl-make-response-handler' is close to useless for this :(,
        ;; because it just `message's for many status codes that are errors for
        ;; us :(
the response had almost no information. which is why its a thunk because you have to recreate that information anyways

stardiviner14:03:52

@dpsutton So flycheck-clojure linters need to update? If yes, will you create an PR for this?

dpsutton14:03:53

Yeah it will need to adapt to the new signatures in the response handler

justinbarclay15:03:58

I use Figwheel to run cljs, and it looks like that CIDER is in a known broken state when it comes to cljs repls. I am wondering, is there a work around for this issue or should I revert to a previous version of CIDER?

justinbarclay15:03:03

Awesome, thanks!

dpsutton15:03:49

got a PR to suppress those checks until we implement them better https://github.com/clojure-emacs/cider/pull/2231

bozhidar15:03:59

@dpsutton I could have committed this immediately, but I didn’t do it because otherwise I won’t really have a motivation to fix the problem.

bozhidar15:03:51

The workaround is trivial, and a relatively simply fix that came to mind mind was grepping the classpath entries.

bozhidar15:03:19

I know people are frustrated, but in general I never commit commented out code. 🙂

dpsutton15:03:40

I agree on the commented out code. I think I would disagree on leaving cider unable to run clojurescript projects as a motivational to fix the issue though. But it is dev and not the stable release

bozhidar15:03:07

I don’t want to keep it broken, but I also don’t have time to fix it and it seems no one else has time as well.

bozhidar15:03:17

I’ll see what I can do.

dpsutton15:03:21

I know your time is tight so I was just offering a potential one click fix while the real solution was in the works

bozhidar15:03:56

I just know how temp solutions often remain permanent, therefore my wariness to just make the validation a no op.

dpsutton15:03:58

I don't have the time either right now otherwise I would tacklw it

dpsutton15:03:10

Super valid concern

dpsutton15:03:43

And I think a very valid priority for a maintainer to impose on projects :)

bozhidar17:03:36

Tested it with Weasel, I assume it will be fine for everything else as well.

dpsutton17:03:45

i'll pull it now and check it on work

bozhidar17:03:01

I also noticed there was no validation for the presence of ClojureScript, so I added that as well.

dpsutton17:03:37

thanks for the fix.

bozhidar17:03:05

You’re welcome! 🙂 I’m just sorry for the breakage I caused before. Down the road it’d be nice to enhance those verifications with some version checking, etc, but this will do for now.

dpsutton17:03:52

no worries. i was fine with going into the codebase and changing it to work for me pending a fix. but that's quite an annoyance to someone who enjoys it and just wants to work

dpsutton17:03:25

cljs is just so tricky to work around

ag17:03:22

so apparently cider-cljs-lein-repl is now deprecated and cider-defaul-cljs-repl needs to be used. But that broke my workflow. Where I can read about this change, to adjust my .dir-locals ?

ag17:03:26

my old setup was:

((nil . ((cider-cljs-lein-repl .
          "(do (require 'figwheel-sidecar.repl-api)
               (require 'integrant.repl)
               (integrant.repl/go)
               (figwheel-sidecar.repl-api/cljs-repl))"))))
simply replacing cider-cljs-lein-repl with cider-default-cljs-repl did not work as I hoped it would

dpsutton18:03:06

@ag you actually have a special case not considered in the code. it was changed to accept "Figwheel" or something similar and it would look up how to start a figwheel repl. however, you have a custom one and it does not allow for a custom repl now (I don't think)

dpsutton18:03:26

but you could try

(add-to-list 'cider-cljs-repl-types 
            `("Figwheel+Integrant"
                     "(do (require 'figwheel-sidecar.repl-api)
               (require 'integrant.repl)
               (integrant.repl/go)
               (figwheel-sidecar.repl-api/cljs-repl))"
               nil))

in your init and then setting cider-default-cljs-repl to "Figwheel+integrant" in your dir locals

dpsutton18:03:38

the reason it might not work is i'm not sure how defconst works with add-to-list

ag18:03:47

I think that worked... now, I'm wondering if I can put the thing above into .dir-locals.el

manuel18:03:49

actually, I was just about to ask: how do we set cider-default-cljs-repl in .dir-locals.el? I tried:

((nil
  (cider-refresh-before-fn . "mount.core/stop")
  (cider-refresh-after-fn . "mount.core/start")
  (cider-default-cljs-repl . "Figwheel"))
 (emacs-lisp-mode
  (flycheck-disabled-checkers . "emacs-lisp-checkdoc")))
but the prompt is still there on cider-jack-in-clojurescript.

richiardiandrea19:03:09

indeed, just watched it!

dpsutton18:03:57

@ag i know you can execute code in dir locals but that stuff gets a little janky. You could use a name that's inoffensive outside of your project. instead of Figwheel+Integrant just call it "<Project-name>startup" and then it doesn't matter that tis visible to other things

dpsutton18:03:28

and this may not be a proper dir locals thing anyways. you are modifying cider's notion of startup invocations

ag18:03:26

I was hoping people don't have to do anything "special" to start working on our project. dir-locals is one way

dpsutton18:03:33

ah i got you. they could just have the checked out dir locals and it would work?

dpsutton18:03:26

have you seen this page on how to eval code in dir locals? You could put the add-to-list call in there https://emacs.stackexchange.com/questions/21955/calling-functions-in-dir-locals-in-emacs

dpsutton18:03:35

yeah that stuff is super murky and has no good feedback

dpsutton18:03:39

honestly i would probably keep everyone on stable until the new api here settles down. i think we're missing one more knob and the logic to check each in turn and then it would be good to go

ag18:03:45

so I did this in .dir-locals.el

((nil . ((eval . (add-to-list 'cider-cljs-repl-types
                              `("Figwheel+Integrant"
                                "(do (require 'figwheel-sidecar.repl-api)
               (require 'integrant.repl)
               (integrant.repl/go)
               (figwheel-sidecar.repl-api/cljs-repl))"
                                nil)))
         (cider-default-cljs-repl . "Figwheel+Integrant"))))

ag18:03:22

and that set the vars correctly, cider-jack-in-clojurescript worked, but... it also prompted for the REPL, I thought it wouldn't

ag18:03:26

but it did work

dpsutton18:03:05

@ag i don't think changing the CIDER code would be that difficult at all. it might be easier to do a PR than muck with side-effecting dir locals

dpsutton18:03:37

just add a var that allows for a custom repl invocation and some logic that does: if custom repl invocation, use that, if type is set, look up how to use it, else ask

dpsutton18:03:57

but up to you 🙂

ag18:03:06

I need quick-n-dirty solution right now... ain't got time for PRs, sorry

dpsutton19:03:17

I'm in the same boat. No worries

wusticality20:03:55

hey all, quick question

wusticality20:03:06

at my new gig they use clojure on the backend and clojurescript on the frontend

wusticality20:03:22

i’m curious whether it’s possible to run a regular cider repl -and- some kind of clojurescript repl at the same time

wusticality20:03:41

it’s really tough to not be able to jump to definition / namespace / etc. in cljs code

dpsutton20:03:21

that's actually the default. when you run cider-jack-in-clojurescript you're gonna end up with two repls. one clj and one cljs

wusticality20:03:14

@dpsutton I think I’m running into some gross issues because they use IntelliJ internally and seem to be loading some Intellij-related clsj in their IDE

wusticality20:03:20

so jacking in totally barfs

wusticality20:03:28

guess i’ll have to debug that on my end

dpsutton20:03:30

what does it say?

dpsutton20:03:35

when it barfs

dpsutton20:03:47

It's saying it's not finding piggie back. Typically this is included on one of the profiles in the project clj file. Cursive is much better at profile support

dpsutton20:03:12

Check and see if you see any references to piggieback in there

dpsutton20:03:06

that's just a dependency for nrepl to talk to cljs in general

wusticality20:03:05

I wonder if it will require editing the config, they might not be happy with me checking something like that in 😕

dpsutton20:03:31

is there not a reference in there?

dpsutton20:03:43

i think cursive does some static analysis so they might not need the nrepl stuff

justinbarclay20:03:46

If you have to edit the config, why not just stash that change as needed? That’s how I do it on my projects so I don’t conflict with my team.

wusticality21:03:47

@emoarmy that’s a workable idea

wusticality21:03:51

yet-another-question

wusticality21:03:07

I have the cider repl running just fine, but jumping to ns et al don’t work

wusticality21:03:20

it’s odd as it lists all the namespaces, but selecting one just says that it’s not found

dpsutton22:03:18

what do you mean "jumping to ns"

dpsutton22:03:24

what cider function are you invoking

wusticality22:03:48

cider-find-ns