Skip to content

hatappo/sublime-clojure

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sublime Text package for Clojure

Note

  • This support only Mac OSX. (I don't have windows...)

Install Manually

git clone https://github.com/hatappo/sublime-clojure
ln -s `pwd`/sublime-clojure $HOME/Library/Application\ Support/Sublime\ Text\ 3/Packages/sublime-clojure

Usage

Build & Run

  • Command + B: Run with Inlein in *.clj, Run with Planck in *.cljs.
  • Command + Shift + B: Execute arbitrary command.

Completions & Snippets

  • Tab or Ctrl + Space

Plugins

Send to REPL

  1. Send a symbol of the cursol with clojure.repl/doc to sublime-REPL.

  2. Send a symbol of the cursol with clojure.repl/source to sublime-REPL.

  3. Send a block of the cursol with clojure.core/macroexpand-1 to sublime-REPL.

  4. Send a block of the cursol with clojure.core/macroexpand to sublime-REPL.

The above commands are not registered in [keymap](Default (OSX).sublime-keymap). You may use on command palette (Command + Shift + P).

Extract inline namespace or package modification

Consider a code like following.

(ns foo-bar.core
  (:import java.util Date)
  (:require [clojure.string :as s]))

(defn aaa [] (clojure.java.io/reader "http://....."))

(defn bbb [] (clojure.java.io/reader "http://....."))

(defn ccc [] (clojure.java.io/reader "http://....."))

Type Ctrl + Command + Shift + n with your cursol is on any position on clojure.java.io/ phrase. Then...

(ns foo-bar.core
  (:import java.util Date)
  (:require [clojure.string :as s]
            [clojure.java.io :as io]))

(defn aaa [] (io/reader "http://....."))

(defn bbb [] (io/reader "http://....."))

(defn ccc [] (io/reader "http://....."))

And all 4 io aliases are automatically selected, so you can change your favorite alias name immediately if you don't like default alias name (io in this case).

Of course, any case is handled well such as no ns form or no require/import phrase.

Features

Leiningen Project Structure Aware

If you edit source code files in a standard leiningen project structure, following features are recognize that.

  • ns snippet.
  • Build commands of Leiningen.sublime-build,
  • and file path in the stack trace.(You can move to the line of the file where the error occurred with double clicking the stack trace in a console.)

Snippets Examples

ns

  1. if you type in ns when you are editing foo-bar/src/foo_bar/baz/aaa.clj which is in a standard leiningen structured project,

  2. then a following snippet is inserted.

(ns foo-bar.baz.aaa
  )

:require

  1. if you type in require,


  2. (:require [namespace :as [namespace]])

  3. And the first namespace text will be automaticaly selected. You can type in a arbitrary namespace text there.

  4. And more, if you type like clojure.java.io, the second namespace which is alias of that is automatically replaced to io.

  5. And if you type in Tab then the alias name io will be selected. You can type in another name if you would not like that.

Files

sublime-completions

sublime-build

  • Leiningen.sublime-build
    Support Leiningen.
    The build settings are wrote by reference to https://gist.github.com/Foredoomed/4103540 .
    The command settings are generated by lein help | grep -E '^[a-z][-a-z]* +[A-Za-z].+$' | awk '{printf(" {\"cmd\": \"lein % -15s \"name\": \"lein %s\"},\n", $1"\",", $0)}'.

  • Inlein.sublime-build
    Support Inlein.
    The command settings are generated by inlein --help | grep '^--[[:alpha:]]*' | awk '{printf(" {\"cmd\": \"inlein % -19s \"name\": \"%s\"},\n", $1"\",", $1)}'.

  • Planck.sublime-build
    Support Planck.

Plugins

  • clojure_inline_namespace_refactoring.py
  • clojure_repl_sender.py

Command Mappings

  • Default (OSX).sublime-keymap
  • Default.sublime-commands

About

Sublime Text3 Plugin for Clojure

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published