Giter Club home page Giter Club logo

clojure.tmbundle's Introduction

textmate-clojure

A TextMate bundle for Clojure. Check out the screencast here.

Installation

This bundle has only been tested with Clojure 1.2.0, though we'd love to hear experience reports about 1.1.0.

$ cd /Applications/TextMate.app/Contents/SharedSupport/Bundles
$ git clone git://github.com/mmcgrana/textmate-clojure.git Clojure.tmbundle
$ osascript -e 'tell app "TextMate" to reload bundles'

RVM Issues

If you are using RVM it is important to follow the TextMate integration instructions pretty closely. More details of the issues on this thread

Cake Integration

This fork adds quite a few commands via Cake which makes the TextMate experience considerably more "Lispy".

First you need to install Cake.

sudo gem install cake

If you already have Cake installed make sure you have at least version 0.5.6.

Tutorial

First steps

Once installed you can create and save a new file with the .clj extension. Type the following expression into this new file and place your cursor as indicated:

(+ 4 5)
-------^

Type Control-X. If you haven't saved the file yet, you will be prompted to do so. The first time you run this command it will take several seconds to see a result. This is because the JVM is starting up. After the first time, Control-X will be much, much, much faster.

Projects

Most of the time you won't be working with single files. You'll be working with projects. Let's make a new project:

cake new hello-world
cd hello-world
mate .

Change your project.clj to look like the following:

(defproject hello-world "0.0.1-SNAPSHOT"
  :description "TODO: add summary of your project"
  :dependencies [[org.clojure/clojure "1.2.0"]])

Then from the command line:

cake deps

Create a source file in your src directory called hello_world.clj. Paste this code into there:

(ns hello-world)

(defn hello-world []
  (println "Hello world!"))

Type Command-Shift-L. This will load your file. You now have a function that you can run. One way is by typing the following and Control-X in the position indicated:

(hello-world)
-------------^

But this would be ignoring the versatility of Cake's REPL. At the command line from your project directory type:

cake repl

This will drop you into the same persistent REPL that your project is using, type the following incomplete sexpr and press the Tab key. This should autocomplete the hello-world namespace:

user=> (in-ns 'he

Close the paren and press enter. You are now in the namespace of the file you are currently working on. Running the hello-world fn from here is an exercise left to the reader ;)

Existing Projects

This bundle works great with your lein projects. Just cd into them and run mate. TextMate will load the directory you can just type Command-R and this will start Cake.

Available Commands

  • Cake Start : Start up a persistent REPL
  • Cake Restart : Restart Cake
  • Load File : load the entire file into the current REPL.
  • Eval : will evaluate the selected code in the current REPL for the project directory.
  • Eval Last Sexpr : will evaluate the sexpr immediate before the cursor
  • Wrap Sexpr : wrap the selected sexpr
  • Unwrap Sexpr : unwrap the selected sexpr
  • Autocomplete : autocomplete a partially typed symbol
  • Show Source : shows the source of the selected function in a new window.
  • Show Doc : shows the document of the selected function in a new window.
  • Jump To Definition : jump to the definition of a symbol (currently only works on files not in jars)
  • Macroexpand : macroexpands the selected sexpr.
  • Macroexpand all : fully macroexpands the selected sexpr.

Hacking & Contributing

This bundle is written almost entirely in Clojure. All commands trigger Clojure scripts which you can find in the bundle under textmate-clojure/Support/bin. Feel free to fork and contribute. There's also a support mailing list here.

Tips

In order to get proper word movement in Clojure you might want to set your Word Characters to _/-.: in the Text Editing tab of the TextMate Preferences window.

For an even more SLIME like experience you could install Visor so that switching to the REPL is just a key-stroke away.

Acknowledgements

This bundle is based on the Based on a previous Clojure bundle by stephenroller and mmcgrana.

clojure.tmbundle's People

Contributors

swannodette avatar jmgimeno avatar mmcgrana avatar mrhus avatar kballenegger avatar gorsuch avatar frou avatar

Stargazers

Vlad Trukhin avatar Chris Zheng avatar

Watchers

James Cloos avatar Chris Zheng avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.