Created
August 31, 2016 17:20
-
-
Save kurogelee/e66303ad9b01e117f341a45dfb0062e3 to your computer and use it in GitHub Desktop.
AtomでClojureの開発環境を構築する ref: http://qiita.com/kurogelee/items/cc8f76cec0718646077a
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def workspace global.atom.workspace) | |
(def commands global.atom.commands) | |
(def views global.atom.views) | |
(defn get-editor [] (.getActiveTextEditor workspace)) | |
(defn get-editor-view [] (.getView views (get-editor))) | |
(defn get-cursor [] (.getLastCursor (get-editor))) | |
(defn get-cursors [] (.getCursors (get-editor))) | |
(defn add-command [name & fs] | |
(.add commands "atom-text-editor" name #(doseq [f fs] (f)))) | |
(defn dispatch [name] (.dispatch commands (get-editor-view) name)) | |
; S式の選択 | |
(add-command "cljs:select-sexp" | |
#(dispatch "lisp-paredit:up-sexp") | |
#(dispatch "lisp-paredit:expand-selection")) | |
; S式内部の選択 | |
(add-command "cljs:select-sexp-inside" | |
#(dispatch "core:move-left") | |
#(dispatch "core:move-right") | |
#(dispatch "bracket-matcher:select-inside-brackets")) | |
; Enter | |
(add-command "cljs:enter" | |
#(if (.isAtEndOfLine (get-cursor)) | |
(dispatch "editor:newline") | |
(dispatch "lisp-paredit:newline"))) | |
; コード実行 | |
(add-command "cljs:execute-block" | |
#(if (pos? (count (.getSelectedText (get-editor)))) | |
(dispatch "proto-repl:execute-selected-text") | |
(dispatch "proto-repl:execute-top-block"))) | |
; 自動で閉じる挙動をOFFにしてシングルクオート | |
(add-command "cljs:single-quote" | |
#(doseq [s (.getSelections (get-editor))] | |
(.insertText s "'"))) | |
; 選択部分のマクロ展開 | |
(add-command "cljs:macro-expand" | |
#(let [s (.getLastSelection (get-editor)) | |
code (str "(macroexpand-1 '" (.getText s) ")") | |
options (clj->js {:inlineOptions {:editor (get-editor) | |
:range (.getBufferRange s)}})] | |
(.executeCodeInNs global.protoRepl code options))) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'atom-text-editor': | |
'ctrl-q': 'tree-view:toggle' | |
'ctrl-t': 'tool-bar:toggle' | |
'atom-workspace atom-text-editor[data-grammar~="clojure"].autocomplete-active': | |
'enter': 'autocomplete-plus:confirm' | |
'atom-text-editor[data-grammar~="clojure"]:not([mini])': | |
'enter': 'cljs:enter' | |
'shift-enter': 'cljs:execute-block' | |
'f4': 'cljs:select-sexp' | |
'f5': 'cljs:select-sexp-inside' | |
'ctrl-i': 'lisp-paredit:indent' | |
'ctrl-d': 'proto-repl:print-var-documentation' | |
'ctrl-delete': 'editor:delete-to-end-of-line' | |
'insert right': 'lisp-paredit:slurp-forwards' | |
'alt-c': 'inline-results:clear-all' | |
'ctrl-e': 'cljs:macro-expand' | |
'&': 'cljs:single-quote' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment