Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c4b1bd3

Browse files
Deraenguns
authored andcommitted
Add indent special case for Reader Conditionals
1 parent f10f8c5 commit c4b1bd3

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
(def DateTime #?(:clj org.joda.time.DateTime,
2+
:cljs goog.date.UtcDateTime))
3+
4+
#?(:cljs
5+
(extend-protocol ToDateTime
6+
goog.date.Date
7+
(-to-date-time [x]
8+
(goog.date.UtcDateTime. (.getYear x) (.getMonth x) (.getDate x)))))
9+
10+
;; vim:ft=clojure:
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
(def DateTime #?(:clj org.joda.time.DateTime,
2+
:cljs goog.date.UtcDateTime))
3+
4+
#?(:cljs
5+
(extend-protocol ToDateTime
6+
goog.date.Date
7+
(-to-date-time [x]
8+
(goog.date.UtcDateTime. (.getYear x) (.getMonth x) (.getDate x)))))
9+
10+
;; vim:ft=clojure:

‎clj/test/vim_clojure_static/indent_test.clj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,8 @@
2323
:in "test-side-effects-in-indentexpr.in"
2424
:out "test-side-effects-in-indentexpr.out"
2525
:keys "\\<CR>:call GetClojureIndent()\\<CR>rxj:call GetClojureIndent()\\<CR>ry"))
26+
27+
(deftest test-reader-conditional-indent
28+
(test-indent "is inherited from previous element"
29+
:in "test-reader-conditional-indent.in"
30+
:out "test-reader-conditional-indent.out"))

‎indent/clojure.vim

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,16 @@ if exists("*searchpairpos")
187187
return val
188188
endfunction
189189

190+
" Check if form is a reader conditional, that is, it is prefixed by #?
191+
" or @#?
192+
function! s:is_reader_conditional_special_case(position)
193+
if getline(a:position[0])[a:position[1] - 3 : a:position[1] - 2] == "#?"
194+
return 1
195+
endif
196+
197+
return 0
198+
endfunction
199+
190200
" Returns 1 for opening brackets, -1 for _anything else_.
191201
function! s:bracket_type(char)
192202
return stridx('([{', a:char) > -1 ? 1 : -1
@@ -254,6 +264,10 @@ if exists("*searchpairpos")
254264
return [paren[0], paren[1] + &shiftwidth - 1]
255265
endif
256266

267+
if s:is_reader_conditional_special_case(paren)
268+
return paren
269+
endif
270+
257271
" In case we are at the last character, we use the paren position.
258272
if col("$") - 1 == paren[1]
259273
return paren

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /