oakes / Nightlight

An embedded editor for Clojure
https://sekao.net/nightlight/
The Unlicense
788 stars 35 forks source link

Instarepl Hoplon file #14

Closed dviius closed 7 years ago

dviius commented 7 years ago

Hi,

I've revised my issue.

I just looked in Nightlight/src/cljs/nightlight/editors.cljs, and see that Nightcode has provision for processing Hoplon files (.hl).

Nightlight appears to be instarepl'ing my cljs files but, doesn't offer the Instarepl switch option for my hoplon code.

I am getting to grips with these tools and, just now, managed to see my first clojurescript instarepl!

Regards,

oakes commented 7 years ago

Would it actually be possible to do this? I thought hoplon files had special implicit requires that normal clojure files didn't. In that case, anything using those requires would fail in the instarepl.

dviius commented 7 years ago

I hope that this is the short answer, from the hoplon wiki, "How is a hl file different?":

A .cljs.hl file is almost the same as a .cljs file. There are two differences:

The .cljs.hl file includes the hoplon and javelin namespaces. And
It can optionally begin with a page form rather than a ns form.

The hoplon compiler uses the page form to know how to make the html files and such. When the hoplon compiler compiles a .hl file into an html file and a cljs file, it only reads the first form (the page declaration). The rest of the file is left as-is, hoplon doesn't even look in there.

The conversion from .hl -> .cljs just involves adding (:require [javelin.core :refer [cell ...]]) and (:require-macros [javelin.core :refer [cell= ...]]) to the ns declaration, because cljs itself doesn't support (:require [javelin.core :refer :all]).

Is the javelin.core reference the implicit require that you speak of? I shall try this code change in my project and see the effect but, I post this in case it is of use to you, even in assisting me!

oakes commented 7 years ago

Yep that's the implicit require. Right now the instarepl will fail since it doesn't require those functions and macros.

oakes commented 7 years ago

I think for now I have to close this until I can think of a simple way of implementing it.