3

作为一个 Clojurian 初学者,我可能需要一些帮助来尝试了解是否有任何方法可以解决我在使用 Cider REPL 时遇到的痛点。

背景:我有一个全栈应用程序(后端的 limunius + 前端的 re-agent/figwheel)。我从 emacs/Cider Repl 启动服务器,并且可以从该 REPL 访问正在运行的服务器的所有命名空间(这非常方便)。

在另一个选项卡中,我运行:

lein figwheel
Figwheel: Cutting some fruit, just a sec ...
Figwheel: Validating the configuration found in project.clj
Figwheel: Configuration Valid ;)
Figwheel: Starting server at http://0.0.0.0:3449
Figwheel: Watching build - app
Compiling build :app to "target/cljsbuild/public/js/app.js" from ["src/cljs" "src/cljc" "env/dev/cljs"]...
Successfully compiled build :app to "target/cljsbuild/public/js/app.js" in 4.113 seconds.
Figwheel: Starting CSS Watcher for paths  ["resources/public/css"]
Figwheel: Starting nREPL server on port: 7002
Launching ClojureScript REPL for build: app

所有 cljs 命名空间都可以从这个 figwheel REPL/tab 访问,但它没有连接到 Cider/emacs,所以我只能在那里复制和粘贴。

有没有一种简单的方法可以在 emacs 中同时拥有两个 REPL 并在它们之间快速切换?

或者您的典型工作流程是什么?您是否使用后端和前端 REPL,但不是同时使用?对不起,我只是在学习,所以我需要两个:)

4

2 回答 2

3

当然可以!cider-connect-clj首先通过在端口 7002 ( ) 上打开的repl 连接到 repl Figwheel: Starting nREPL server on port: 7002,然后(figwheel-sidecar.repl-api/cljs-repl)在弹出的 repl minibuffer 中运行。然后,您将拥有与 clj repl 一起运行的功能齐全的 cljs repl - 您可以在它们之间切换cider-switch-to-repl-buffer(在 clj 文件中时,您将被带到 clj repl,在 cljs 文件中时,您将被带到 cljs repl)

于 2020-04-18T12:36:19.680 回答
2

您绝对可以使用 CIDER 同时连接到 CLJ 和 CLJS。检查CIDER 文档中的管理连接部分。TL;DR:您可以使用C-c C-x c m来调用cider-connect-clj&cljs.

话虽如此,对于 CLJS,我通常是一个懒惰的人,我让 figwheel 在保存时重新编译,我检查前端是否像我想要做的那样。

编辑:我的设置通常是两个垂直框架,左侧的代码和右侧的 REPL,大多数时候评估内联表达式C-c C-e,如果我需要跨越多行的任何内容,我将它写在(comment ,,,)命名空间末尾的块上. 我不C-C C-z经常在代码和 REPL 之间切换。

另外:我在 Ubuntu 18.04 中使用库存的 Emacs 25 并进行了最少的设置,但我遇到过使用 Spacemacs 的工作流程更加复杂的人。

于 2020-04-18T06:54:03.050 回答