lynaghk / cljx

Write a portable codebase targeting Clojure/ClojureScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting cljx to work in LightTable

bcachet opened this issue · comments

Hello,

I'm trying to get cljx files be parsed correctly by Light Table. First I try to be able to use load-file from the REPL.

From cljx README, I only need to install cljx as a plugin, but it doesn't work.

So I tried to use cljx.repl-middleware/wrap-cljx nrepl middleware.

To perform my experiment, I tried to load cljx file from Schema configured REPL which is of the following:

:profiles {:dev {:dependencies [[org.clojure/clojure "1.5.1"]
                                  [org.clojure/clojurescript "0.0-2030"]
                                  [com.keminglabs/cljx "0.3.1"]]
                   :plugins [[com.keminglabs/cljx "0.3.1"]
                             [lein-cljsbuild "0.3.2"]
                             [com.cemerick/austin "0.1.3"]
                             [com.cemerick/clojurescript.test "0.2.2"]]
                   :hooks [leiningen.cljsbuild]
                   :repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl
                                                     cljx.repl-middleware/wrap-cljx]}}}

When I launch lein repl, cljx generates the cljs/clj files and cljsbuild generate javascript. When done, if I tried to load a cljx file *(load-file "test/cljx/schema/test_test.cljx") I got the following error:

nREPL server started on port 57898 on host 127.0.0.1
REPL-y 0.3.0
Clojure 1.5.1
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e

user=> (load-file "test/cljx/schema/test_test.cljx")

CompilerException java.lang.RuntimeException: No reader function for tag +clj, compiling:(/Users/bertrand/Desktop/schema/test/cljx/schema/test_test.cljx:2:28)

Can you explain me how to make it work ?

Sincerely

Bertrand

What about the plugin doesn't work?

Be sure you're using the latest cljx, either [com.keminglabs/cljx "0.3.2"] or ideally [com.keminglabs/cljx "0.3.3-SNAPSHOT"].

Any code-loading forms that accept a namespace are supported by the middleware, e.g. require, load, load-namespace in ClojureScript, etc. load-file accepts only a "raw" file path, which cljx cannot hook easily.

I hope this helps?

Hello @cemerick

First, thanks for your help.

When I say that the plugin doesn't work, I mean I got the same result as with explicitly calling cljx middleware.

I use [com.keminglabs/cljx "0.3.3-SNAPSHOT"]

As you said, require or load work as expected. But not load-file (reading code of cljx.repl_middleware/wrap-cljx I thought it should handle .cljx file)

Can you give me advice on how to evaluate correctly cljx file from the REPL ? It will be very helpful to evaluate cljx file from Light Table.

Sincerely

The load-file you're seeing in the middleware source file is the nREPL command of the same name.

Does LightTable support connecting to nREPL endpoints? If so, then evaluating expressions from .cljx files and within the REPL should work, as should full-file loads. I've not looked at LightTable in some time, so that's about as much advice I can provide immediately…perhaps a post in the LightTable mailing list would turn up someone that's worked out whatever details are involved? If so, please do post a link back here.

Light Table support connecting to nREPL endpoints.
I create a connection to the REPL I started from Leiningen but it doesn't manage to evaluate .cljx file because of the same error I gave you.

I will post a question on the Light Table mailing list and come back to you if I got any information.

Thanks a lot for your time.

Yeah, I can't suggest anything further without digging into how LightTable's nREPL support is set up. Please do report back; in the meantime, perhaps I'll get a chance to investigate properly.