Skip to content

Instantly share code, notes, and snippets.

@casperc
Forked from laurentpetit/lein_headless.clj
Created May 11, 2014 18:06
Show Gist options
  • Save casperc/e1fe946a9c2fc9a05cbb to your computer and use it in GitHub Desktop.
Save casperc/e1fe946a9c2fc9a05cbb to your computer and use it in GitHub Desktop.
(ns lein-headless
(:require [ccw.e4.dsl :refer [defcommand defhandler defkeybinding]]
[ccw.e4.model :refer [context-key]])
(:import [ccw.launching ClojureLaunchShortcut]))
(defn run
"Try to start a Leiningen Project. If focus is on a ClojureEditor, then first
try to launch from the editor project, else try to launch from the selection."
[context]
(let [editor (context-key context org.eclipse.ui.IEditorPart)]
(cond
(instance? ccw.editors.clojure.ClojureEditor editor)
(future
(-> (ClojureLaunchShortcut.)
(.launch editor nil)))
:else
(future
(-> (ClojureLaunchShortcut.)
(.launch (context-key context :active-selection) nil))))))
(defcommand run-lein-headless "RUN as Leiningen Project")
(defhandler run-lein-headless run)
(defkeybinding run-lein-headless "Alt+L P")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment