Skip to content

Commit 9b5e42c

Browse files
committed
Discovered a way to put comments within dict defs in Vim script
1 parent 01edfec commit 9b5e42c

File tree

1 file changed

+30
-45
lines changed

1 file changed

+30
-45
lines changed

indent/clojure.vim

+30-45
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@ setlocal softtabstop=2 shiftwidth=2 expandtab
2323
setlocal indentkeys=!,o,O
2424

2525
" Set a new configuration option with a default value. Assigns a script-local
26-
" version too, which is the default fallback in case the global was "unlet".
26+
" version too, to be used as a default fallback if the global was "unlet".
2727
function! s:SConf(name, default) abort
28-
let s = 's:' . a:name
29-
let n = 'g:' . a:name
28+
let [s, g] = ['s:' . a:name, 'g:' . a:name]
3029
exec 'let' 's:' . a:name '=' string(a:default)
31-
if ! exists(n) | exec 'let' n '=' s | endif
30+
if ! exists(g) | exec 'let' g '=' s | endif
3231
endfunction
3332

3433
" Get the value of a configuration option with a possible fallback.
@@ -51,47 +50,33 @@ call s:SConf('clojure_fuzzy_indent_patterns', [
5150
\ ])
5251

5352
" Defaults copied from: https://github.com/clojure-emacs/clojure-mode/blob/0e62583b5198f71856e4d7b80e1099789d47f2ed/clojure-mode.el#L1800-L1875
54-
if !exists('g:clojure_indent_rules')
55-
let g:clojure_indent_rules = {
56-
\ 'ns': 1,
57-
\ 'fn': 1, 'def': 1, 'defn': 1, 'bound-fn': 1, 'fdef': 1,
58-
\ 'let': 1, 'binding': 1, 'defmethod': 1,
59-
\ 'if': 1, 'if-not': 1, 'if-some': 1, 'if-let': 1,
60-
\ 'when': 1, 'when-not': 1, 'when-some': 1, 'when-let': 1, 'when-first': 1,
61-
\ 'case': 1, 'cond': 0, 'cond->': 1, 'cond->>': 1, 'condp': 2,
62-
\ 'while': 1, 'loop': 1, 'for': 1, 'doseq': 1, 'dotimes': 1,
63-
\ 'do': 0, 'doto': 1, 'comment': 0, 'as->': 2,
64-
\ 'delay': 0, 'future': 0, 'locking': 1,
65-
\ 'try': 0, 'catch': 2, 'finally': 0,
66-
\ 'reify': 1, 'proxy': 2, 'defrecord': 2, 'defprotocol': 1, 'definterface': 1,
67-
\ 'extend': 1, 'extend-protocol': 1, 'extend-type': 1
68-
\ }
69-
" (letfn) (1 ((:defn)) nil)
70-
" (reify) (:defn (1))
71-
" (deftype defrecord proxy) (2 nil nil (:defn))
72-
" (defprotocol definterface extend-protocol extend-type) (1 (:defn))
73-
74-
" ClojureScript
75-
call extend(g:clojure_indent_rules, {
76-
\ 'this-as': 1, 'specify': 1, 'specify!': 1
77-
\ })
78-
" (specify specify!) (1 :defn)
79-
80-
" clojure.test
81-
call extend(g:clojure_indent_rules, {
82-
\ 'deftest': 1, 'testing': 1, 'use-fixtures': 1, 'are': 2
83-
\ })
84-
85-
" core.async
86-
call extend(g:clojure_indent_rules, {
87-
\ 'alt!': 0, 'alt!!': 0, 'go': 0, 'go-loop': 1, 'thread': 0
88-
\ })
89-
90-
" core.logic
91-
call extend(g:clojure_indent_rules, {
92-
\ 'run': 1, 'run*': 1, 'fresh': 1
93-
\ })
94-
endif
53+
call s:SConf('clojure_indent_rules', {
54+
\ 'ns': 1,
55+
\ 'fn': 1, 'def': 1, 'defn': 1, 'bound-fn': 1, 'fdef': 1,
56+
\ 'let': 1, 'binding': 1, 'defmethod': 1,
57+
\ 'if': 1, 'if-not': 1, 'if-some': 1, 'if-let': 1,
58+
\ 'when': 1, 'when-not': 1, 'when-some': 1, 'when-let': 1, 'when-first': 1,
59+
\ 'case': 1, 'cond': 0, 'cond->': 1, 'cond->>': 1, 'condp': 2,
60+
\ 'while': 1, 'loop': 1, 'for': 1, 'doseq': 1, 'dotimes': 1,
61+
\ 'do': 0, 'doto': 1, 'comment': 0, 'as->': 2,
62+
\ 'delay': 0, 'future': 0, 'locking': 1,
63+
\ 'try': 0, 'catch': 2, 'finally': 0,
64+
\ 'reify': 1, 'proxy': 2, 'defrecord': 2, 'defprotocol': 1, 'definterface': 1,
65+
\ 'extend': 1, 'extend-protocol': 1, 'extend-type': 1,
66+
"\ (letfn) (1 ((:defn)) nil)
67+
"\ (reify) (:defn (1))
68+
"\ (deftype defrecord proxy) (2 nil nil (:defn))
69+
"\ (defprotocol definterface extend-protocol extend-type) (1 (:defn))
70+
"\ ClojureScript
71+
\ 'this-as': 1, 'specify': 1, 'specify!': 1,
72+
"\ (specify specify!) (1 :defn)
73+
"\ clojure.test
74+
\ 'deftest': 1, 'testing': 1, 'use-fixtures': 1, 'are': 2,
75+
"\ core.async
76+
\ 'alt!': 0, 'alt!!': 0, 'go': 0, 'go-loop': 1, 'thread': 0,
77+
"\ core.logic
78+
\ 'run': 1, 'run*': 1, 'fresh': 1
79+
\ })
9580

9681
" Returns "1" if position "i_char" in "line_str" is preceded by an odd number
9782
" of backslash characters (i.e. escaped).

0 commit comments

Comments
 (0)