77" License: Vim (see :h license)
88" Repository: https://github.com/clojure-vim/clojure.vim
99
10+ " NOTE: To debug this code, make sure to "set debug+=msg" otherwise errors
11+ " will occur silently.
12+
1013if exists (" b:did_indent" ) | finish | endif
1114let b: did_indent = 1
1215
@@ -19,9 +22,6 @@ setlocal noautoindent nosmartindent nolisp
1922setlocal softtabstop = 2 shiftwidth = 2 expandtab
2023setlocal indentkeys = ! ,o ,O
2124
22- " NOTE: To debug this code, make sure to "set debug+=msg" otherwise errors
23- " will occur silently.
24-
2525if ! exists (' g:clojure_fuzzy_indent_patterns' )
2626 let g: clojure_fuzzy_indent_patterns = [
2727 \ ' ^with-\%(meta\|in-str\|out-str\|loading-context\)\@!' ,
@@ -30,41 +30,48 @@ if !exists('g:clojure_fuzzy_indent_patterns')
3030 \ ]
3131endif
3232
33+ " TODO: are all these options needed or relevant? Use "lispwords" instead?
34+ " Defaults copied from: https://github.com/clojure-emacs/clojure-mode/blob/0e62583b5198f71856e4d7b80e1099789d47f2ed/clojure-mode.el#L1800-L1875
3335if ! exists (' g:clojure_indent_rules' )
34- " Defaults copied from: https://github.com/clojure-emacs/clojure-mode/blob/0e62583b5198f71856e4d7b80e1099789d47f2ed/clojure-mode.el#L1800-L1875
3536 let g: clojure_indent_rules = {
3637 \ ' ns' : 1 ,
37- \ ' fn' : 1 , ' def' : 1 , ' defn' : 1 , ' bound-fn' : 1 ,
38+ \ ' fn' : 1 , ' def' : 1 , ' defn' : 1 , ' bound-fn' : 1 , ' fdef' : 1 ,
39+ \ ' let' : 1 , ' binding' : 1 , ' defmethod' : 1 ,
3840 \ ' if' : 1 , ' if-not' : 1 , ' if-some' : 1 , ' if-let' : 1 ,
3941 \ ' when' : 1 , ' when-not' : 1 , ' when-some' : 1 , ' when-let' : 1 , ' when-first' : 1 ,
4042 \ ' case' : 1 , ' cond' : 0 , ' cond->' : 1 , ' cond->>' : 1 , ' condp' : 2 ,
4143 \ ' while' : 1 , ' loop' : 1 , ' for' : 1 , ' doseq' : 1 , ' dotimes' : 1 ,
4244 \ ' do' : 0 , ' doto' : 1 , ' comment' : 0 , ' as->' : 2 ,
4345 \ ' delay' : 0 , ' future' : 0 , ' locking' : 1 ,
44- \ ' fdef' : 1 ,
45- \ ' extend' : 1 ,
4646 \ ' try' : 0 , ' catch' : 2 , ' finally' : 0 ,
47- \ ' let' : 1 , ' binding' : 1 ,
48- \ ' defmethod' : 1 ,
49- \ ' this-as' : 1 ,
50- \ ' deftest' : 1 , ' testing' : 1 , ' use-fixtures' : 1 , ' are' : 2 ,
51- \ ' alt!' : 0 , ' alt!!' : 0 , ' go' : 0 , ' go-loop' : 1 , ' thread' : 0 ,
52- \ ' run' : 1 , ' run*' : 1 , ' fresh' : 1
47+ \ ' reify' : 1 , ' proxy' : 2 , ' defrecord' : 2 , ' defprotocol' : 1 , ' definterface' : 1 ,
48+ \ ' extend' : 1 , ' extend-protocol' : 1 , ' extend-type' : 1
5349 \ }
54-
55- " (letfn '(1 ((:defn)) nil))
56- " (proxy '(2 nil nil (:defn)))
57- " (reify '(:defn (1)))
58- " (deftype '(2 nil nil (:defn)))
59- " (defrecord '(2 nil nil (:defn)))
60- " (defprotocol '(1 (:defn)))
61- " (definterface '(1 (:defn)))
62- " (extend-protocol '(1 :defn))
63- " (extend-type '(1 :defn))
64- " (specify '(1 :defn)) ; ClojureScript
65- " (specify! '(1 :defn)) ; ClojureScript
66- " (this-as 1) ; ClojureScript
67- " clojure.test, core.async, core.logic
50+ " (letfn) (1 ((:defn)) nil)
51+ " (reify) (:defn (1))
52+ " (deftype defrecord proxy) (2 nil nil (:defn))
53+ " (defprotocol definterface extend-protocol extend-type) (1 (:defn))
54+
55+ " ClojureScript
56+ call extend (g: clojure_indent_rules , {
57+ \ ' this-as' : 1 , ' specify' : 1 , ' specify!' : 1
58+ \ })
59+ " (specify specify!) (1 :defn)
60+
61+ " clojure.test
62+ call extend (g: clojure_indent_rules , {
63+ \ ' deftest' : 1 , ' testing' : 1 , ' use-fixtures' : 1 , ' are' : 2
64+ \ })
65+
66+ " core.async
67+ call extend (g: clojure_indent_rules , {
68+ \ ' alt!' : 0 , ' alt!!' : 0 , ' go' : 0 , ' go-loop' : 1 , ' thread' : 0
69+ \ })
70+
71+ " core.logic
72+ call extend (g: clojure_indent_rules , {
73+ \ ' run' : 1 , ' run*' : 1 , ' fresh' : 1
74+ \ })
6875endif
6976
7077" Get the value of a configuration option.
0 commit comments