Skip to content

Commit 9e6878e

Browse files
authored
Correctly indent splicing reader conditionals (#14)
Adjusts is_reader_conditional_special_case to also match splices, i.e. #?@. The test case is taken from <https://clojure.org/guides/reader_conditionals>. Previously reader splicing conditionals were indented as if they were functions, e.g. #?@(:clj [5 6 7 8] :cljs [1 2 3 4])))
1 parent bd2a734 commit 9e6878e

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

clj/dev-resources/test-reader-conditional-indent.in

+3
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@
77
(-to-date-time [x]
88
(goog.date.UtcDateTime. (.getYear x) (.getMonth x) (.getDate x)))))
99

10+
#?@(:clj [5 6 7 8]
11+
:cljs [1 2 3 4])))
12+
1013
;; vim:ft=clojure:

clj/dev-resources/test-reader-conditional-indent.out

+3
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@
77
(-to-date-time [x]
88
(goog.date.UtcDateTime. (.getYear x) (.getMonth x) (.getDate x)))))
99

10+
#?@(:clj [5 6 7 8]
11+
:cljs [1 2 3 4])))
12+
1013
;; vim:ft=clojure:

indent/clojure.vim

+2-1
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,10 @@ if exists("*searchpairpos")
215215
endfunction
216216

217217
" Check if form is a reader conditional, that is, it is prefixed by #?
218-
" or @#?
218+
" or #?@
219219
function! s:is_reader_conditional_special_case(position)
220220
return getline(a:position[0])[a:position[1] - 3 : a:position[1] - 2] == "#?"
221+
\|| getline(a:position[0])[a:position[1] - 4 : a:position[1] - 2] == "#?@"
221222
endfunction
222223

223224
" Returns 1 for opening brackets, -1 for _anything else_.

0 commit comments

Comments
 (0)