Fork me on GitHub
#hoplon
<
2016-04-06
>
jouerose11:04:13

hi all. has anybody managed to get clojure support (syntax highlighting) for *.cljs.hl files in Atom io Editor ? cheers

jouerose11:04:05

i have managed to set it for .boot files but not *.cljs.hl files. thanks for the help

micha11:04:53

@jouerose: maybe try setting clojure syntax mode for all *.hl files?

micha11:04:30

like maybe the two-level extension confuses it

genRaiy11:04:38

what’s up with https://github.com/hoplon/hoplon/wiki/HLisp … what can I do to help document HLISP? Seems like its one of Hoplon’s killer features!

jouerose11:04:22

@micha: Atom does not accept '*' or '.' at the beginning of the file extension. for .boot files i just put "boot" in the list of clojure source. for cljs.hl i tried nothing happens, for hl also nothing

micha11:04:43

@jouerose: did you try just "hl"?

genRaiy11:04:52

Seems like this is the closest to human readable documentation https://github.com/hoplon/hoplon/wiki/API-Documentation

micha11:04:03

@jouerose: that should work, no?

micha11:04:14

or do you use the html syntax also?

genRaiy11:04:26

@dm3 that’s good background but does not document the actual usage

dm311:04:44

yep, I mean if you want to write an HLisp wiki page

dm311:04:52

you can use that as the theoretical part

jouerose11:04:09

@micha it should but it does not.

micha11:04:48

does Atom have anything like vim modelines?

genRaiy11:04:54

@dm3 ah, ok 😉 thanks

jouerose11:04:08

@micha i suspect the dot in the middle of cljs.hl is a special case Atom doesnt treat

jouerose11:04:20

@micha not a user of vim. i do not know

micha11:04:22

like in vim i can do ;; vim: set ft=clojure:

micha11:04:28

at the top of the file

micha11:04:36

that tells it to consider the file a clojure file

micha11:04:10

vim has a mechanism by which you can add editor settings to the file itself

micha11:04:18

and when it reads the file it will apply those settings

jouerose11:04:49

@micha humm that's neat.

micha11:04:06

emacs has a similar thing, and maybe Atom has that too

jouerose11:04:26

@micha i think i am going to stick to lighttable for now (see if there is autocomplete) and jump into hoplon learning

micha11:04:24

@jouerose: are you experienced with lisp programming already?

jouerose11:04:49

@micha i am a beginner

jouerose11:04:53

with clojure

micha11:04:23

one thing about lisp is that you don't need autocomplete as much as with an OO language

micha11:04:46

because in most cases autocomplete would amount to "what is the programmer thinking"

micha11:04:15

because the functions whose names you would be completing are general and can be applied to any object

jouerose11:04:28

@micha i see. i guess it is the "library exploration" aspect of autocomplete which attracts me. instead of always opening some doc

micha11:04:41

not like the way you have the same kind of method named different things on different obejcts

jouerose11:04:42

@micha interesting point indeed

micha11:04:03

or missing on this class but not on that class, etc

micha11:04:20

with clojure there are relatively few methods that can be applied on anything

micha11:04:27

basically clojure.core namespace

micha11:04:47

i've never really used autocomplete in clojure, myself

micha11:04:58

other than the dumb autocomplete the editor does

micha11:04:14

like just if i use a string in the file i can tab complete it later if i use it again

micha11:04:45

most of what you do is accomplished by composing just maybe 10 or 20 functions from clojure.core

micha11:04:24

map, filter, reduce, assoc, dissoc, group-by, sort, sort-by, partition, interpose, partial, apply, comp, juxt

micha11:04:29

the repl has autocomplete

micha11:04:49

which is probably a good way to explore a namespace

jouerose11:04:23

the design of the language renders less necessary some other tools, i see

jouerose11:04:33

thanks for the write up

micha11:04:41

like i can't program c# without an IDE

micha11:04:01

because it's impossible to keep the class hierarchy in my head

piotrek11:04:07

Hi, I have a question about hoplon and semantic-ui library

piotrek11:04:23

I am trying to use its UI widgets, e.g. dropdown

jouerose11:04:44

@micha what do you think of Onsen UI ?

micha11:04:05

@jouerose: i'm not familiar with it

dm311:04:12

don't you even use vim-fireplace, Micha?

piotrek11:04:39

I tried following:

micha11:04:40

@dm3: yes vim fireplace works great for clojure

jouerose11:04:43

@micha not familiar with it yet, planning on using it as it seems it will do well for desktop and mobile web app

micha11:04:29

@dm3: i like how minimal vim-fireplace is, it does all the things i need really

micha11:04:50

and i don't need to tinker with it

piotrek11:04:50

Unfortunately, when semantic-ui selects the value it overwrites my value (which is initially a cell) with a plain string value

dm311:04:51

yep, thought you went completely hardcore for a second there

piotrek11:04:55

How should I use it?

micha12:04:20

@dm3: the main thing is that i don't want to be running the bleeding edge unstable stuff in my editor

jouerose12:04:26

@micha is there a plan to abstract websocket/channels in hoplon like you have already done with http ?

micha12:04:40

it makes me sad to spend my time playing around with editor config

dm312:04:53

haven't touched mine in a couple years

dm312:04:02

although I do :BundleInstall from time to time

micha12:04:13

totally, vundle ftw

micha12:04:26

what do you use to manage your workspace?

dm312:04:34

on OSX - amethyst

micha12:04:36

i've been using ctrlspace, which is pretty good

micha12:04:42

i mean inside vim

dm312:04:06

not much, really. ctrl+p and bufexplorer

dm312:04:09

and nerdtree

dm312:04:26

one vim per project

micha12:04:29

ah cool, that's how i used to do it, i'm not sure if ctrlspace is a win or not

dm312:04:58

tiling is via amethyst/xmonad

micha12:04:26

i've been trying to get into spacemacs, but there isn't anything good for managing my workflow in there

dm312:04:15

I've tried to get into spacemacs for a month. Half of plugins aren't evilified

micha12:04:20

@jouerose: yes i think websockets can be supported very nicely as a middleware layer wrapping castra

micha12:04:40

@jouerose: so your application code can still be just functions

dm312:04:40

then it just feels slower

micha12:04:07

@dm3: yeah that's what i found, too

jouerose12:04:31

@micha it is something i hope to see in Hoplon. the framework has started quite well. it would be great to have this aspect of realtime baked in.

micha12:04:01

i don't mind using emacs keybindings inside a plugin or whatever, but the combination of everything being slightly slower and not having a way to set up tabs and buffers and things like i can in vim makes it too cumbersome

micha12:04:35

like with vim my keypresses are mostly deterministic

micha12:04:47

but with spacemax it's mostly fuzzy search which is nondeterministic

micha12:04:55

and that extra 100ms starts to add up then

dm312:04:30

the nicest thing was the integrated repl

dm312:04:43

but vim-fireplace kinda has something like that

dm312:04:57

also the debugging, which I sometimes wish I had in VIM

micha12:04:03

yeah i usually start a repl in tmux and connect to that from vim

micha12:04:23

so i can just switch tmux buffer to be in the repl

dm312:04:26

@jouerose: there's https://github.com/hoplon/notify, although it's a bit convoluted

micha12:04:37

and fireplace does pretty much what i need for in-editor repl

jouerose12:04:13

@dm3 thanks. will check it out.

dm312:04:09

@piotrek - seems noone is aware of the semantic library here, guess @onetom could help once he's online

piotrek12:04:09

@dm3 thanks for the hint, I will ping @onetom

jouerose12:04:28

@micha when you have time, would like to know your opinion on Onsen UI. cheers

micha12:04:53

@jouerose: i'll definitely look into it, thanks for the tip!

micha12:04:45

@piotrek: you're using the semantic-ui js stuff?

micha12:04:23

i think @onetom mostly uses just the css part and implements the js part in cljs

micha12:04:49

most things should be simple to reimplement in hoplon

micha12:04:58

well simpler than the original js anyway

micha12:04:38

another approach would be to look at the js semantic uses and see if you can attach cells to functions in there

micha12:04:48

rather than to the dom elements themseleves

micha12:04:16

like maybe the widget has getters and setters you can hook into with a cell

piotrek12:04:23

I am looking for a rich components library with good widgets

piotrek12:04:31

and semantic-ui seems good

piotrek12:04:54

I’m not js/css expert simple_smile

piotrek12:04:03

so I want to build using existing components

micha12:04:27

unfortunately i'm not familiar with how semantic ui does the js side

micha12:04:35

does it make jquery plugins?

micha12:04:42

that's how bootstrap does it

micha12:04:54

and those are pretty easy to wire up to cells

piotrek12:04:07

I think it does (plugins)

piotrek12:04:42

as I can simply do $(“#my-ui-widget”).dropdown() where dropdown comes from semantic-ui

micha12:04:46

so what i would do is see if you can find getters and setters and events on the widget's js object

micha12:04:06

and you can attach watches to cells to trigger those

micha12:04:26

and have event handlers that set the value in the cell when the user change the value via the ui

micha12:04:34

in the widget

piotrek12:04:02

I will try it - thanks

micha12:04:20

alan shows the pattern there

micha12:04:27

for hoplonizing a jquery plugin

micha12:04:42

you can usually turn a jquery plugin into a hoplon custom element very easily

piotrek12:04:48

One more question

piotrek12:04:38

When I use library like jquery, where I define some component (like in my snippet) I have to add some init code (e.g. $(“#my-ui-widget”).dropdown())

piotrek12:04:04

what is the idiomatic way to handle this init code especially if I define a reusable defelem returning such components?

dm312:04:37

it's a bit complicated as it tries to manage the state of multiple datepickers

dm312:04:54

only letting the "current" one to be open

dm312:04:20

(with-init!
        (cell= (doto (js/jQuery elem) destroy (create opts)))

dm312:04:41

this is how the plugin is reinitialized based on the updated opts cell (or the first time)

leontalbot12:04:28

@jouerose: Regarding .cljs.hl support syntax in Atom editor, have you read this?

"*":
  core:
    customFileTypes:
      "source.clojure": [
        "cljs\.hl"
      ]

piotrek12:04:00

hmm, I wrapped my init into with-init! but I am getting error in console: Transition: Element is no longer attached to DOM. Unable to animate. slide down in <div class="menu" tabindex="-1">…</div>

piotrek12:04:30

I just translated a js version into hoplon

dm312:04:41

first, you want to only act on the element that you've created: (doto (js/jQuery p) (.dropdown))

leontalbot12:04:39

@jouerose: or simply this :

"*":
  core:
    customFileTypes:
      "source.clojure": [
        "hl"
      ]

piotrek12:04:31

@dm3 OK, I have changed it but still the same error

piotrek13:04:27

so it looks like my element might be removed somehow from the DOM?

piotrek13:04:37

could hoplon remove it?

piotrek13:04:50

That’s all I have (+dependency on [cljsjs/semantic-ui "2.1.8-0”])

dm313:04:50

doto ... should be in a cell=

dm313:04:06

although...

dm313:04:30

you don't have any dependencies there

leontalbot13:04:36

@jouerose: maybe a last possibility "cljs\\.hl"

dm313:04:55

@piotrek, maybe the semantic-ui javascript is doing something funky there. I don't see why the element would get detached

piotrek13:04:43

That’s strange

piotrek13:04:35

When I added an empty element at the end of the ui dropdown div it works fine...

dm313:04:11

seems like semantic ui problem

piotrek13:04:18

@dm3 thanks for your help

piotrek13:04:05

@micha I have done as you suggested - I registered my onChange listener on the semantic-ui component and my listener updates a cell passed as a param to my defelem element

piotrek13:04:15

@micha thanks for your suggestion

jouerose14:04:48

@micha @leontalbot thank you for your help. I understood my 3 misunderstandings regarding the configuration of cljs.hl syntax highlight support in Atom editor. 1) support of boot files comes already with the core clojure language support. 2) I had placed customFileTypes at the end of file but order matters and it must be under the "core:" title like in the example @leontalbot gave. i checked and there is no need to espace characters "cljs.hl" works fine. "hl" also. 3) inside the customFilesTypes, the scope called "source.clojure" was written "clojure.source". Thanks all for your help.

leontalbot14:04:54

I can I translate the following in hoplon?

window.onload = function() { init() };
 function init() {
   Tabletop.init( { key: public_spreadsheet_url,
                    callback: showInfo,
                    simpleSheet: true } );
 }

leontalbot14:04:00

I've included js library to head but I get Uncaught ReferenceError: Tabletop is not defined while doing the following

jouerose14:04:28

@leontalbot: i am new. i am going to learn too simple_smile

micha14:04:39

@jouerose: if you have a moment and would like to make a note on the wiki about how you did it that would be most appreciated! simple_smile

micha14:04:17

@leontalbot: the issue you're seeing is that script tags will load async

micha14:04:39

a bettwe way to do that is to make the js into a cljsjs package that you can depend on in your project

micha14:04:47

the it will be concatenated with main.js or whatever

micha14:04:53

so you won't have that problem

leontalbot14:04:07

(with-init!
  (.init js/Tabletop
         (clj->js
                      {:key sheet-key
                       :callback #(reset! sheet-data @%)
                       :simpleSheet true})))

micha14:04:36

otherwise, if you don't want to do that you can use the jQuery.getScript("/somescript.js", function() { callback here })

micha15:04:10

@leontalbot: yeah when with-init! runs the script hasn't yet finished loading

leontalbot15:04:23

A cljsjs package is something I can do locally or I must push to clojar?

leontalbot15:04:47

ok, I try that!

micha15:04:17

you can do it locally too, yes

micha15:04:42

but making a package would be something the community can help with, which is good

onetom15:04:47

@piotrek: we are using semantic ui CSS only and hardly missed anything from the js parts indeed

onetom15:04:09

good point though that there is nothing under https://github.com/exicon/hoplon-semantic-ui-example i got stuck with it because at that time less4j couldnt compile the less source of semantic ui. we ended up using the vanilla default build instead. whoever i tried the boot-sass task w bourbon and foundation and i have some instructions for that here: http://hoplon.discoursehosting.net/t/trying-to-create-a-boot-task-to-compile-sass-files/386/9

onetom15:04:52

thanks to deraen there is also a boot task for LESS: https://github.com/Deraen/less4clj so u can follow the same principle and just get the semantic ui less source from webjars: http://www.webjars.org/listfiles/org.webjars.bower/semantic-ui/2.1.8

onetom16:04:48

@piotrek: here is an example of a hoplonified semantic ui dropdown:

(defelem multiselect-dropdown [{:keys [items placeholder on-change]}]
  (let [visible? (cell false)
        sorted-items (cell= (sort items))
        selected-items #(filter :selected (vals @items))]
    (div :class (cell= {"ui fluid multiple selection dropdown" true
                        "active visible"                       visible?})
         :mousedown #(reset! visible? true)
         (i :class "dropdown icon")
         (loop-tpl
           :bindings [item (cell= (filter #(:selected (val %)) sorted-items))]
           (a :class "ui label transition visible" (cell= (when item (:title (val item))))
              :mousedown #(do
                           (swap! items assoc-in [(key @item) :selected] false)
                           (on-change (selected-items)))
              (i :class "delete icon")))
         (div :class "default text" placeholder)
         (div :class (cell= {"menu transition" true "visible" visible?})
              :tabindex "-1"
              :focus visible?
              :blur #(reset! visible? false)
              (loop-tpl
                :bindings [item sorted-items]
                (div :class (cell= {"item"            true
                                    "active filtered" (:selected (val item))})
                     :click #(do
                              (swap! items assoc-in [(key @item) :selected] true)
                              (on-change (selected-items)))
                     (cell= (:title (val item)))))))))

onetom16:04:19

example usage:

(defc fields-data nil)

(def resolutions
  (cell {:720x1280 {:title "720x1280"}
         :540x960  {:title "540x960"}
         :1280x800 {:title "1280x800"}
         :1280x720 {:title "1280x720"}
         :1024x600 {:title "1024x600"}
         :320x480  {:title "320x480"}
         :320x320  {:title "320x320"}
         :240x400  {:title "240x400"}
         :480x800  {:title "480x800"}
         :360x640  {:title "360x640"}
         :240x320  {:title "240x320"}}))

(ui/multiselect-dropdown :items resolutions
                         :placeholder "Choose at least one"
                         :on-change #(swap! fields-data assoc :supported-resolutions (map :title %)))

jouerose17:04:22

hi all. in the boot.properties file there is BOOT_CLOJURE_VERSION=1.7.0 and in the build.boot there is a dependency [org.clojure/clojure "1.7.0"] . what is the relation between the two ? is there any one that overrides another ? thanks for letting me know. cheers

flyboarder18:04:33

@jouerose: BOOT_CLOJURE_VERSION is the version of clojure that boot uses for itself, [org.clojure/clojure "1.7.0”] is the project dependency version of clojure

jouerose18:04:48

@flyboarder: if i were to bump up the boot clojure version to 1.8.0 do you think it would be ok or would i may be be messing with it ?

flyboarder18:04:15

@alandipert @micha would have a better idea on the stability of using 1.8 with boot, I think it would depend on what tasks you are using

alandipert18:04:31

i use 1.8 all the time

alandipert18:04:39

my only problems are from libraries that don't work with 1.8

alandipert18:04:02

e.g. some popular clojure libraries that are shipped with AOT'd clojure, like older versions of cheshire

alandipert18:04:09

usually the fix it to update that dependency

alandipert18:04:31

instaparse is another one - contains non-forward compat AOT'd clojure bytecode

alandipert18:04:53

but yeah, boot itself is fully 1.8 compat

alandipert18:04:07

(afaict ™️ )

onetom22:04:34

i haven't had any issues with 1.8 either im even running on java 9ea