nbb

Daniel Gerson 2022-10-13T08:35:57.490919Z

Morning. I suspect the following promesa snippet isn't right?

(p/done? (p/rejected (ex-info "test" {})))
  ;; => No protocol method IState.-pending? defined for type object: [object Promise]

borkdude 2022-10-13T09:00:53.029769Z

lemme check

borkdude 2022-10-13T09:10:00.535079Z

I get the same error in regular CLJS so it's not nbb-specific at least

Daniel Gerson 2022-10-13T09:29:33.652699Z

Filed #118

Daniel Gerson 2022-10-13T09:30:09.142129Z

(meant one thread down 😆 )

borkdude 2022-10-13T09:31:51.262839Z

thanks

borkdude 2022-10-13T09:11:11.018579Z

cljs.user=> (p/done? (p/delay 100))
Execution error (Error) at (<cljs repl>:1).
No protocol method IState.-pending? defined for type object: [object Promise]
Perhaps file an issue with promesa

Daniel Gerson 2022-10-13T09:22:03.298149Z

Thanks for checking.

Benjamin 2022-10-13T19:06:18.090599Z

the cljs.core library is not present in nbb, scittle nor joyride is that correct?

borkdude 2022-10-13T19:07:18.286449Z

it's called clojure.core in all of those

borkdude 2022-10-13T19:07:25.231309Z

why?

Benjamin 2022-10-13T19:08:42.760109Z

(defun cider--check-cljs (&optional cljs-type no-error)
  "Verify that all cljs requirements are met for CLJS-TYPE connection.
Return REPL-TYPE of requirement are met, and throw an 'user-error' otherwise.
When NO-ERROR is non-nil, don't throw an error, issue a message and return
nil."
  (if t
      (condition-case ex
          (progn
            (cider-verify-clojurescript-is-present)
            (cider-verify-cljs-repl-requirements cljs-type))
        (error
         (message "Invalid ClojureScript dependency: %S" ex)
         nil))
    (cider-verify-clojurescript-is-present)
    (cider-verify-cljs-repl-requirements cljs-type)))
I can make a quick hack with this function, be ok with cljs.core not being there and i get a nice nbb repl

borkdude 2022-10-13T19:09:20.167449Z

Well, this does work: cljs.core/inc in all of those environments. What exactly does CIDER execute?

Benjamin 2022-10-13T19:09:52.741449Z

(defun cider-verify-clojurescript-is-present ()
  "Check whether ClojureScript is present."
  (unless (cider-library-present-p "cljs.core")
    (user-error "ClojureScript is not available.  See  for details")))
checks "cljs.core"

Benjamin 2022-10-13T19:10:32.630399Z

1 sec

borkdude 2022-10-13T19:12:35.893569Z

Perhaps you can convince CIDER to change this into cljs.core/inc which does work for SCI CLJS environments

borkdude 2022-10-13T19:13:45.590539Z

In JVM Clojure you can't just type clojure.core and expect a result, so this isn't implemented. It seems more an artifact than a supported feature in CLJS

Benjamin 2022-10-13T19:14:41.804389Z

you know what is funny? I think the only issue is that most repls return "nil" and nbb returns nil when evaling a require function call

Benjamin 2022-10-13T19:15:23.124059Z

ah nvm. I tries to eval (require 'cljs.core)

Benjamin 2022-10-13T19:29:47.986999Z

for completeness, here is my cider proposal https://github.com/clojure-emacs/cider/issues/3255

mkvlr 2022-10-13T20:30:56.006079Z

@benjamin.schwerdtner really appreciate your efforts here, would love to see the default experience improve here, thank you! 🙏

✔️ 1
➕ 1
😅 1
Benjamin 2022-10-14T12:33:25.803479Z

turns out I needed to workaround a little more. This elisp should work, should somebody desire a jack-in-nbb command right now: https://benjamin-asdf.github.io/faster-than-light-memes/jacking-nbb.html

borkdude 2022-10-14T12:36:10.041029Z

@benjamin.schwerdtner Cool, worth sharing here in the main channel. I'll also link it from nbb's README

👍 1
Benjamin 2022-10-13T19:07:53.647939Z

(defun mm/cider-connected-hook ()
  (when (eq 'nbb-or-scittle-or-joyride cider-cljs-repl-type)
    (setq-local cider-show-error-buffer nil)
    (cider-set-repl-type 'cljs)))

(add-hook 'cider-connected-hook #'mm/cider-connected-hook)

(defun mm/cider-jack-in-nbb ()
  (interactive)
  (cider-jack-in-cljs
   '(:jack-in-cmd
     "nbb nrepl-server"
     :cljs-repl-type
     nbb-or-scittle-or-joyride)))
because this kinda works good. Except that cider checks for cljs.core lib and throws an error.