Skip to content

Instantly share code, notes, and snippets.

View laurentpetit's full-sized avatar

Laurent Petit laurentpetit

View GitHub Profile
(defn create-control [parent]
(let [c (composite parent
::project-name-group create-project-name-group
::create-in-group create-in-group
::lein-template-group create-lein-template-group)
$ (partial $ c)]
(config! ($ ::create-in-group)
:form-data {:top {:control ::project-name-group}
:left {:pct 0}
:right {:pct 100}})
nrepl exception while doing code completion:
Exception in thread "nREPL-worker-2" java.lang.IllegalArgumentException: No implementation of method: :send of protocol: #'clojure.tools.nrepl.transport/Transport found for class: clojure.tools.nrepl.middleware.pr_values$pr_values$fn$reify__1283
at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:541)
at clojure.tools.nrepl.transport$eval7291$fn__7292$G__7280__7299.invoke(transport.clj:16)
at clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__7726$fn__7739.invoke(interruptible_eval.clj:75)
at clojure.main$repl$fn__6597.invoke(main.clj:279)
at clojure.main$repl.doInvoke(main.clj:277)
at clojure.lang.RestFn.invoke(RestFn.java:1096)
at clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__7726.invoke(interruptible_eval.clj:56)
@laurentpetit
laurentpetit / nrepl_events.clj
Created December 19, 2013 14:26
Adds 2 launch event listeners that spit the created nrepl server port into ~/.nrepl and <project-dir>/.nrepl files
(ns nrepl-events
(:require [ccw.core.launch :as l]
[clojure.java.io :as io]
[ccw.eclipse :as e]))
(defn spit-globally
"global ~/.nrepl file"
[{:keys [event-type port project]}]
(when (= :creation event-type)
(spit (io/file (java.lang.System/getProperty "user.home") ".nrepl")
;; What do you prefer?
(def options {:option-1 SomeClass/OPTION_1})
(defn foo [ option ]
(if (keyword? option)
(options option)
option))
;; Or
@laurentpetit
laurentpetit / plugin_additions.clj
Last active December 31, 2015 02:59
A Counterclockwise User Plugin adding a Command for reloading User Plugins from the ~/.ccw directory ( Alt+U S ) . How cool / meta is that, heh ? :-)
(ns plugin-additions
(:require [clojure.java.io :as io]
[ccw.e4.dsl :refer :all]
[ccw.e4.model :as m]
[ccw.eclipse :as e]
[ccw.file :as f]
[ccw.core.user-plugins :as p]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@laurentpetit
laurentpetit / lein_popup.clj
Created December 11, 2013 12:41
Place this file inside ~/.ccw/, or clone the gist inside ~/.ccw/lein-popup, and start/restart your Eclipse.
(ns lein-popup
(:require [ccw.e4.dsl :refer :all]
[ccw.leiningen.generic-launch :refer (generic-launch)]))
(defn launch [context] (generic-launch nil))
(defcommand launch-lein-generic "Launch generic leiningen popup")
(defhandler launch-lein-generic launch)
(defkeybinding launch-lein-generic "Alt+L G")
(ns hello-world
(:require [ccw.eclipse :as e]
[ccw.e4.dsl :refer :all]))
(defn greet [context]
(e/info-dialog
"Hello world" "This popup provided to you from a user script"))
(defcommand greeter "Hello from CCW")
(defhandler greeter greet)
(ns lein-script-test
(:require [ccw.util.e4.dsl :refer :all]
[ccw.util.eclipse :as e]
[ccw.leiningen.generic-launch :as l]))
(defn greet [context]
(e/info-dialog "Hello world" "This popup provided to you from a user script"))
(defn launch [context] (l/generic-launch nil))
@laurentpetit
laurentpetit / explicit.clj
Last active December 29, 2015 16:29
Les 2 codes suivants sont strictement equivalents en termes de side-effects
(ns lein-script-test
(:require [ccw.util.eclipse :as e]
[ccw.util.e4.model :refer (merge! app]))
(defn greet [context] (e/info-dialog "Hello world" "This popup provided to you from a user script"))
(merge! @app
{:commands [{:element-id "lein-script-test/greeter"
:command-name "Hello from CCW"}]
:handlers [{:command "lein-script-test/greeter"
@laurentpetit
laurentpetit / lein-script-test.clj
Last active December 29, 2015 15:48
place script.clj in ~/.ccw
(ns lein-script-test
(:require [ccw.util.eclipse :as e]))
(defn greet [context]
(e/info-dialog "Hello world"
"This popup provided to you from a user script"))
(defn handler-factory [context] (ccw.util.GenericHandler. #'greet))
;; last form of the script is an application model fragment to be merged into the Application Model