简体   繁体   English

有没有更简单的方法可以从 emacs/cider 同时使用 CLJ + CLJS REPL?

[英]Is there an easier way to use BOTH clj + cljs REPLs at the same time from emacs/cider?

As a beginner Clojurian I may need some help trying to understand if there is any way to solve my pain points of working with Cider REPL.作为一个 Clojurian 初学者,我可能需要一些帮助来尝试了解是否有任何方法可以解决我在使用 Cider REPL 时遇到的痛点。

Context: I have a full-stack app(limunius on backend + re-agent/figwheel on frontend).背景:我有一个全栈应用程序(后端的 limunius + 前端的 re-agent/figwheel)。 I start the server from emacs/Cider Repl and can access all the namespaces of the running server from that REPL(which is super handy).我从 emacs/Cider Repl 启动服务器,并且可以从该 REPL 访问正在运行的服务器的所有命名空间(这非常方便)。

In another tab I run:在另一个选项卡中,我运行:

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

All cljs namespaces are accessible from this figwheel REPL/tab but it is not connected to Cider/emacs so I can only copy and paste there.所有 cljs 命名空间都可以从这个 figwheel REPL/tab 访问,但它没有连接到 Cider/emacs,所以我只能在那里复制和粘贴。

Is there a simple way to have both REPLs in emacs and quickly switch between them?有没有一种简单的方法可以让 emacs 中的两个 REPL 并在它们之间快速切换?

Or what's your typical workflow?或者您的典型工作流程是什么? Do you use backend and frontend REPLs but not at the same time?您是否使用后端和前端 REPL,但不是同时使用? Sorry, I'm just learning so I need both:)对不起,我只是在学习,所以我需要两个:)

Certainly you can!当然可以! First connect to repl via cider-connect-clj that was opened on port 7002 ( Figwheel: Starting nREPL server on port: 7002 ), then run (figwheel-sidecar.repl-api/cljs-repl) in the repl minibuffer that popped up.首先通过在端口 7002 上打开cider-connect-clj连接到 repl ( Figwheel: Starting nREPL server on port: 7002 ),然后在弹出的 repl minibuffer 中运行(figwheel-sidecar.repl-api/cljs-repl) . Then you'll have fully functioning cljs repl running along with clj repl - you can switch between them with cider-switch-to-repl-buffer (you will be taken to clj repl when in clj file, and to cljs repl when in cljs file)然后,您将拥有与 clj repl 一起运行的功能齐全的 cljs repl - 您可以使用cider-switch-to-repl-buffer在它们之间切换(在 clj 文件中时您将被带到 clj repl,在 cljs 中时将被带到 cljs repl文件)

You definitely can connect to both CLJ and CLJS at the same time with CIDER.您绝对可以使用 CIDER 同时连接到 CLJ 和 CLJS。 Check the section Managing Connections from the CIDER docs.检查 CIDER 文档中的管理连接部分。 TL;DR : you can use Cc Cx c m to call cider-connect-clj&cljs . TL;DR :您可以使用Cc Cx c m调用cider-connect-clj&cljs

That being said, for CLJS in general I'm a lazy and I leave figwheel to recompile on save and I check if the front-end looks like what I'm trying to do.话虽如此,对于 CLJS,我通常是一个懒惰的人,我让 figwheel 在保存时重新编译,我检查前端是否像我想要做的那样。

Edit : My setup is generally two vertical frames, code on the left and REPL on the right, most of the time evaluate expressions inline with Cc Ce and if I need anything that spans for multiple lines I write it on a (comment,,,) block at the end of a namespace.编辑:我的设置通常是两个垂直框架,左侧的代码和右侧的 REPL,大多数时候评估与Cc Ce内联的表达式,如果我需要跨越多行的任何内容,我将它写在(comment,,,)块在命名空间的末尾。 I don't use CC Cz to switch between code and REPL very frequently.我不经常使用CC Cz在代码和 REPL 之间切换。

Also: I use stock Emacs 25 in Ubuntu 18.04 with a minimal setup but I've met people that have much more elaborate workflows using Spacemacs.另外:我在 Ubuntu 18.04 中使用库存 Emacs 25 并进行了最少的设置,但我遇到过使用 Spacemacs 拥有更精细工作流程的人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM