Skip to content

Instantly share code, notes, and snippets.

@laurentpetit
Created May 6, 2014 20:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save laurentpetit/8365fe68924eb42a97b1 to your computer and use it in GitHub Desktop.
Save laurentpetit/8365fe68924eb42a97b1 to your computer and use it in GitHub Desktop.
User plugin for expliciting starting a leiningen project from an editor or from a selected file/project.
(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