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 8ee73c5

Browse files
committed
Small refactor to improve code clarity in indentation code
1 parent bdbc281 commit 8ee73c5

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

‎indent/clojure.vim‎

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -85,28 +85,23 @@ function! s:InsideForm(lnum)
8585
" Reduce tokens from line "lnum" into "tokens".
8686
for tk in s:TokeniseLine(lnum)
8787
if tk[0] ==# '"'
88-
" Keep track of the first string delimiter we
89-
" see, as we'll need it later for multi-line
90-
" strings/regexps.
91-
if first_string_pos == []
92-
let first_string_pos = tk[1]
93-
endif
94-
95-
if ! empty(tokens) && tokens[-1][0] ==# '"'
88+
if in_string
9689
let in_string = 0
9790
call remove(tokens, -1)
9891
else
9992
let in_string = 1
10093
call add(tokens, tk)
101-
endif
102-
103-
continue
104-
endif
105-
106-
" When in string ignore other tokens.
107-
if in_string | continue | endif
10894

109-
if ! empty(tokens) && get(s:pairs, tk[0], '') ==# tokens[-1][0]
95+
" Track the first string delimiter we
96+
" see, as we may need it later for
97+
" multi-line strings/regexps.
98+
if first_string_pos == []
99+
let first_string_pos = tk
100+
endif
101+
endif
102+
elseif in_string
103+
" In string: ignore other tokens.
104+
elseif ! empty(tokens) && get(s:pairs, tk[0], '') ==# tokens[-1][0]
110105
" Matching pair: drop the last item in tokens.
111106
call remove(tokens, -1)
112107
else
@@ -115,9 +110,8 @@ function! s:InsideForm(lnum)
115110
endif
116111
endfor
117112

118-
" echom 'Pass' lnum tokens
119-
120113
if ! empty(tokens) && has_key(s:pairs, tokens[0][0])
114+
" Match found!
121115
return tokens[0]
122116
endif
123117

@@ -127,7 +121,7 @@ function! s:InsideForm(lnum)
127121
if ! empty(tokens) && tokens[0][0] ==# '"'
128122
" Must have been in a multi-line string or regular expression
129123
" as the string was never closed.
130-
return ['"', first_string_pos]
124+
return first_string_pos
131125
endif
132126

133127
return ['^', [0, 0]] " Default to top-level.
@@ -191,8 +185,7 @@ function! s:ClojureIndent()
191185
endif
192186
endfunction
193187

194-
" TODO: set lispoptions if exists.
195-
" https://github.com/vim/vim/commit/49846fb1a31de99f49d6a7e70efe685197423c84
188+
" TODO: setl lisp lispoptions=expr:1 if exists. "has('patch-9.0.0761')"
196189
setlocal indentexpr=s:ClojureIndent()
197190

198191
let &cpoptions = s:save_cpo

0 commit comments

Comments
(0)

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