Skip to content
Browse files

Plug-in has moved

  • Loading branch information...
1 parent 7d338c1 commit 2e401a5513b3cbf86ed1fcaad72891ed9180dae3 @sattvik committed Apr 14, 2012
Showing with 2 additions and 304 deletions.
  1. +2 −107 README.md
  2. +0 −7 project.clj
  3. +0 −190 src/leiningen/vimclojure.clj
View
109 README.md
@@ -1,108 +1,3 @@
-# lein-vimclojure
+This plug-in has been renamed to `lein-tarsier` and is now available at:
-A fully-featured Leiningen plugin to run a VimClojure server for Leiningen
-projects.
-
-## Why another VimClojure plug-in?
-
-There are already a number of VimClojure plug-ins out there, some of them
-called lein-nailgun and others called lein-vimclojure. However, most of them
-tend to be fairly minimal. In particular, most of them lacked two key features:
-
-1. Support for both Leiningen 1.x and Leiningen 2.x projects, and
-2. The ability to run a standalone REPL in the same process as the server.
-
-## Installation
-
-While you can install this plug-in by adding it to the `:plugins` vector of
-your `project.clj`, it probably makes more sense to install it as a user-level
-plug-in.
-
-### Leiningen 2
-
-Add `[com.sattvik/lein-vimclojure "0.9.0"]` to the `plugins` vector of your `:user`
-profile located in `~/.lein/profiles.clj`. For example:
-
-```clj
- {:user {:plugins [[com.sattvik/lein-vimclojure "0.9.0"]]}}
-```
-
-### Leiningen 1
-
-Just run:
-
- lein plugin install com.sattvik/lein-vimclojure 0.9.0
-
-## Use
-
-Once the plug-in is installed, running it is as easy as:
-
- lein vimclojure
-
-The plug-in accepts some arguments, described in the next section.
-
-## Configuration
-
-This plug-in supports the following configuration options:
-
-* `:host`, the host name to use for the VimClojure server, defaults to
- `"127.0.0.1"`
-* `:port`, the port the VimClojure server will listen on, defaults to `2113`
-* `:repl`, a boolean value determining whether the plug-in should launch a
- REPL, defaults to `false`
-
-You may set these options as follows.
-
-### Profile-based configuration (Leiningen 2 only)
-
-You can set these options using the profile feature of Leiningen 2. For
-example:
-
-```clj
- {:user {:plugins [[com.sattvik/lein-vimclojure "0.9.0"]]
- :vimclojure-opts {:repl true
- :port 42}}}
-```
-
-### Project-based configuration
-
-Additionally, you can modify your `project.clj` and add a `:vimclojure-opts`
-mapping, for example:
-
-```clj
- (defprojct foo "1.0.0"
- :vimclojure-opts {:repl true
- :port 42})
-```
-
-### Command line override
-
-Finally, you can override any profile- or project-based settings at the command line:
-
- lein vimclojure :repl true :port 42
-
-## Overriding the VimClojure server version
-
-This plug-in is configured to use version 2.3.1 of the VimClojure server by
-default. However, you can override this by manually specifying the dependency
-in your project.
-
-For example, to use version 2.2.0 of the server, you could add the following
-dependency to your project:
-
- [vimclojure/server "2.2.0"]
-
-## TODO
-
-There are a number of features that may be added to the plug-in:
-
-* The ability to run an initialisation script when launching the server
-* Adding more features the REPL, such as ClojureDocs support
-* The ability to hook onto other Leiningen commands
-
-## License
-
-Copyright © 2012 Sattvik Software & Technology Resources, Ltd. Co.
-All rights reserved.
-
-Distributed under the Eclipse Public License, the same as Clojure.
+https://github.com/sattvik/lein-tarsier/tree/0.9.1
View
7 project.clj
@@ -1,7 +0,0 @@
-(defproject com.sattvik/lein-vimclojure "0.9.1-SNAPSHOT"
- :description "Launches a VimClojure server for Vim."
- :url "https://github.com/sattvik/lein-vimclojure"
- :license {:name "Eclipse Public License"
- :url "http://www.eclipse.org/legal/epl-v10.html"}
- :dependencies [[trammel "0.7.0"]]
- :eval-in-leiningen true)
View
190 src/leiningen/vimclojure.clj
@@ -1,190 +0,0 @@
-(ns leiningen.vimclojure
- "Adds VimClojure server support to a Leiningen project."
- (:use [trammel.core :only [defconstrainedfn]])
- (:import java.net.InetAddress))
-
-(def ^{:private true
- :doc "The name of the VimClojure dependency."}
- vimclojure-package
- 'vimclojure/server)
-
-(def ^{:private true
- :doc "The version of VimClojure to include."}
- vimclojure-version
- "2.3.1")
-
-(def ^{:private true
- :doc "The VimClojure dependency."}
- vimclojure-dep
- [vimclojure-package vimclojure-version :exclusions ['org.clojure/core]])
-
-(def ^{:private true
- :doc "Default values for the plug-in options."}
- default-opts
- {:host (InetAddress/getByName "127.0.0.1")
- :port 2113
- :repl false})
-
-(defconstrainedfn try-resolve
- "Attempts to resolve the given namespace-qualified symbol. If successful,
- returns the resolved symbol. Otherwise, returns nil."
- [sym]
- [symbol? namespace]
- (let [ns-sym (symbol (namespace sym))]
- (try (require ns-sym)
- (resolve sym)
- (catch java.io.FileNotFoundException _))))
-
-(defn- eval-in-project
- "Support eval-in-project for both Leiningen 1.x and 2.x. This code is
- inspired from the code in the lein-swank plug-in."
- [project form]
- (let [eip (or (try-resolve 'leiningen.core.eval/eval-in-project)
- (try-resolve 'leiningen.compile/eval-in-project))]
- (eip project form)))
-
-(defconstrainedfn read-keys
- "Take a key-value pair and reads the key ensuring the result is a keyword."
- [[k v]]
- [(string? k) (string? v) => (fn [k2 v2] (and (keyword? k2) (= v v2)))]
- [(read-string k) v])
-
-(defconstrainedfn args->options
- "Process the command line arguments for the vimclojure plug-in, converting
- them to a map of keywords to string values."
- [args]
- [(even? (count args))]
- (->> args
- (partition 2)
- (mapcat read-keys)
- (apply hash-map)))
-
-(defmulti to-inetaddress
- "Converts the argument into an InetAddress instance."
- {:post [#(instance? InetAddress %)]}
- type)
-
-(defmethod to-inetaddress InetAddress [addr] addr)
-(defmethod to-inetaddress String [s] (InetAddress/getByName s))
-(defmethod to-inetaddress :default [x] (to-inetaddress (str x)))
-
-(defconstrainedfn to-boolean
- "Converts the argument into a boolean value."
- [x]
- [=> #(instance? Boolean %)]
- (boolean (Boolean/valueOf (str x))))
-
-(defconstrainedfn to-int
- "Converts the argument to an integer."
- [n]
- [=> integer? pos?]
- (if (number? n)
- (int n)
- (Integer/parseInt (str n))))
-
-(defn get-options
- "Gets the options from the defaults, the project, and the command line
- arguments."
- [project args]
- (merge default-opts
- (:vimclojure-opts project)
- (args->options args)))
-
-(defn validate-options
- "Validates the options to make sure they contain valid values."
- [options]
- (-> options
- (update-in [:host] to-inetaddress)
- (update-in [:port] to-int)
- (update-in [:repl] to-boolean)))
-
-(defconstrainedfn has-vimclojure-dep?
- "Returns a value that evaluates to true if the project has a
- vimclojure/server dependency."
- [project]
- [(vector? (:dependencies project))]
- (some #(= vimclojure-package (first %)) (:dependencies project)))
-
-(defconstrainedfn add-vimclojure-dep
- "Adds the VimClojure server as a dependency of the project."
- [project]
- [=> has-vimclojure-dep?]
- (if (has-vimclojure-dep? project)
- project
- (update-in project [:dependencies] conj vimclojure-dep)))
-
-(defconstrainedfn get-vimclojure-opt
- "Gets the value of the given plug-in option from the project."
- [project opt]
- [(:vimclojure-opts project)]
- (get-in project [:vimclojure-opts opt]))
-
-(defconstrainedfn run-server-form
- "Generates a form that will run the server and cleanly it shut down when the
- user interrupts the process."
- [host port]
- `(let [server# (~'vimclojure.nailgun.NGServer.
- (java.net.InetAddress/getByName ~host)
- (Integer/parseInt ~port))
- shutdowner# (Thread. (reify Runnable
- (run [_]
- (.shutdown server# false))))]
- (.. (Runtime/getRuntime) (addShutdownHook shutdowner#))
- (println (str "Starting VimClojure server on " ~host ", port " ~port))
- (println "Happy hacking!")
- (.run server#)))
-
-(defconstrainedfn run-repl-form
- "Generates a form that will run the server in the background and provide a
- REPL in the foreground. The server will shut down when the REPL terminates."
- [host port]
- `(let [server# (~'vimclojure.nailgun.NGServer.
- (java.net.InetAddress/getByName ~host)
- (Integer/parseInt ~port))
- thread# (Thread. server#)]
- (println (str "Starting VimClojure server on " ~host ", port " ~port))
- (.start thread#)
- (println "Clojure" (clojure-version))
- (clojure.main/repl)
- (.shutdown server# false)))
-
-
-(defconstrainedfn vimclojure-form
- "Generates a form to be evaluated in the project's context."
- [project]
- [has-vimclojure-dep?
- (instance? InetAddress (get-vimclojure-opt project :host))
- (integer? (get-vimclojure-opt project :port))
- ]
- ;=>
- ;(instance? clojure.lang.Cons %)]
- (let [host (.getHostAddress (get-vimclojure-opt project :host))
- port (str (get-vimclojure-opt project :port))]
- (if (get-vimclojure-opt project :repl)
- (run-repl-form host port)
- (run-server-form host port))))
-
-(defn vimclojure
- "Launches a VimClojure server.
-
- This plug-in understands the following options:
-
- :host the host name to use for opening the server (default: 127.0.0.1)
-
- :port the port on which the server will listen (default: 2113)
-
- :repl if true, in addition to starting the server, starts a REPL (default: false)
-
- These options may be supplied in your project.clj as the value of
- ':vimclojure-opts' or on the command lein, as in:
-
- lein vimclojure :repl true
-
- Command line options override project options."
- [project & args]
- (let [options (-> (get-options project args)
- (validate-options))
- project (-> project
- add-vimclojure-dep
- (update-in [:vimclojure-opts] merge options))]
- (eval-in-project project (vimclojure-form project))))

0 comments on commit 2e401a5

Please sign in to comment.
Something went wrong with that request. Please try again.