【问题标题】:Unable to evaluate ClojureScript using fireplace.vim when using the Clojure CLI使用 Clojure CLI 时无法使用 firefox.vim 评估 ClojureScript
【发布时间】:2020-04-25 02:48:01
【问题描述】:

我期待着尝试使用 the new release of ClojureScript,但在尝试评估代码时遇到了问题。

我有一个 nREPL 服务器正在运行,并且(似乎?)能够使用 :Fireplaceconnect localhost:$PORT 连接到它。但是,当我尝试评估代码(使用:Eval:CljsEval)时,我看到一条错误消息,上面写着“Fireplace: no default ClojureScript REPL”。

firewall.vim 存储库中有 an issue 提到了这个问题,但它已被 RTFM 关闭——我有,但我仍然无法找到解决方案。

~/.clojure/deps.edn

{
  :aliases {:nREPL
             {:extra-deps
               {nrepl/nrepl {:mvn/version "0.7.0"}
                cider/piggieback {:mvn/version "0.4.2"}}}}
}

启动 nrepl

> clj -R:nREPL -m nrepl.cmdline --middleware "[cider.piggieback/wrap-cljs-repl]"

【问题讨论】:

  • 看起来您的别名不需要 clojurescript:github.com/benknoble/Dotfiles/blob/…
  • 感谢您的建议。我已经尝试将该条目添加到我的别名中并作为全局依赖项,它不会改变任何东西。另外,不管它值多少钱,我的别名直接取自 Piggieback 文档。您如何使用在链接的 deps.edn 中定义的别名?
  • Tbh 我已经好几个月没有使用 clojurescript 壁炉连接了(尽管我上面的常规 clojure 壁炉连接最近得到了很好的锻炼)。
  • 不确定它是否能解决您的问题,但至少它为我摆脱了Fireplace: no default ClojureScript REPL。按照此处所述启动 repl:github.com/nrepl/piggieback 并输入:(require 'cljs.repl.node) 然后在 vim 中您可以执行 :CljEval (cider.piggieback/cljs-repl (cljs.repl.node/repl-env))
  • 我不是为了要点;-)如果你让整个事情发挥作用,你可以写一个答案作为参考。我还没有找到在 vim/fireplace 中开发 Clojurescript 的解决方案,它实际上对我有用......

标签: vim clojurescript vim-plugin


【解决方案1】:

我找到了一个可行的解决方案并记录了整个工作流程here

deps.edn:

{
 :aliases {:rebel {:main-opts ["-m" "rebel-readline.main"]}}
 :paths ["src" "resources" "target"]
 :deps {cider/cider-nrepl {:mvn/version "0.25.0-alpha1"}
        cider/piggieback {:mvn/version "0.5.0"}
        com.bhauman/figwheel-main {:mvn/version "0.2.6"}
        com.bhauman/rebel-readline {:mvn/version "0.1.4"}
        com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"}
        nrepl/nrepl {:mvn/version "0.7.0"}
        org.clojure/clojure {:mvn/version "1.10.1"}
        org.clojure/clojurescript {:mvn/version "1.10.773"}
        reagent {:mvn/version "0.10.0"
                 :exclusions [cljsjs/react cljsjs/react-dom]}}}

在 Clojure REPL 中运行以下命令来启动 nREPL 服务器、ClojureScript REPL 和 Figwheel 构建:

(require '[fullstack.helpers :refer :all])  ;; import nREPL helpers
(start-nrepl-server!)                       ;; start nREPL server on 7888

;; Some people run the following commands using Vim-Fireplace's `:CljEval`
;; command but I found that to be a little clunky.
;; If I do end up using this workflow regularly, I'll consider packaging these
;; steps up in a VimScript helper function.
;; Out of habit, I send them from this document inside vim to a parallel tmux
;; pane using vim-slime.

(require 'figwheel.main.api)    ;; require Figwheel's scripting API
(figwheel.main.api/start "dev") ;; start Figwheel build (using dev.cljs.edn) and REPL

在 Vim 中,在 CLI 提示符下运行以下命令(在命令模式下点击 :)以连接到正在运行的 ClojureScript REPL:

:Piggieback (figwheel.main.api/repl-env "dev") " connect to the CLJS REPL

主要区别在于将依赖项移动到本地 deps.edn(这不是必需的,但我认为这是一种更好、更灵活的方法),升级 Piggieback 并依靠更高级别的 Figwheel 脚本 API,而不是 CLI 标志.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-19
    • 2018-04-02
    • 1970-01-01
    • 2016-09-28
    相关资源
    最近更新 更多