@@ -57,27 +57,30 @@ if exists("*searchpairpos")
57
57
let g: clojure_align_subforms = 0
58
58
endif
59
59
60
- function ! s: SynIdName ()
60
+ function ! s: syn_id_name ()
61
61
return synIDattr (synID (line (" ." ), col (" ." ), 0 ), " name" )
62
62
endfunction
63
63
64
- function ! s: CurrentChar ()
64
+ function ! s: ignored_region ()
65
+ return s: syn_id_name () = ~? ' \vstring|regex|comment|character'
66
+ endfunction
67
+
68
+ function ! s: current_char ()
65
69
return getline (' .' )[col (' .' )-1 ]
66
70
endfunction
67
71
68
- function ! s: CurrentWord ()
72
+ function ! s: current_word ()
69
73
return getline (' .' )[col (' .' )-1 : searchpos (' \v>' , ' n' , line (' .' ))[1 ]-2 ]
70
74
endfunction
71
75
72
- function ! s: IsParen ()
73
- return s: CurrentChar () = ~# ' \v[\(\)\[\]\{\}]' &&
74
- \ s: SynIdName () !~? ' \vstring|regex|comment|character'
76
+ function ! s: is_paren ()
77
+ return s: current_char () = ~# ' \v[\(\)\[\]\{\}]' && ! s: ignored_region ()
75
78
endfunction
76
79
77
80
" Returns 1 if string matches a pattern in 'patterns', which may be a
78
81
" list of patterns, or a comma-delimited string of implicitly anchored
79
82
" patterns.
80
- function ! s: MatchesOne (patterns, string )
83
+ function ! s: match_one (patterns, string )
81
84
let list = type (a: patterns ) == type ([])
82
85
\ ? a: patterns
83
86
\ : map (split (a: patterns , ' ,' ), ' "^" . v:val . "$"' )
@@ -86,7 +89,7 @@ if exists("*searchpairpos")
86
89
endfor
87
90
endfunction
88
91
89
- function ! s: MatchPairs (open , close , stopat)
92
+ function ! s: match_pairs (open , close , stopat)
90
93
" Stop only on vector and map [ resp. {. Ignore the ones in strings and
91
94
" comments.
92
95
if a: stopat == 0
@@ -95,11 +98,11 @@ if exists("*searchpairpos")
95
98
let stopat = a: stopat
96
99
endif
97
100
98
- let pos = searchpairpos (a: open , ' ' , a: close , ' bWn' , " !s:IsParen ()" , stopat)
101
+ let pos = searchpairpos (a: open , ' ' , a: close , ' bWn' , " !s:is_paren ()" , stopat)
99
102
return [pos[0 ], virtcol (pos)]
100
103
endfunction
101
104
102
- function ! s: ClojureCheckForStringWorker ()
105
+ function ! s: clojure_check_for_string_worker ()
103
106
" Check whether there is the last character of the previous line is
104
107
" highlighted as a string. If so, we check whether it's a ". In this
105
108
" case we have to check also the previous character. The " might be the
@@ -113,17 +116,17 @@ if exists("*searchpairpos")
113
116
114
117
call cursor (nb , 0 )
115
118
call cursor (0 , col (" $" ) - 1 )
116
- if s: SynIdName () !~? " string"
119
+ if s: syn_id_name () !~? " string"
117
120
return -1
118
121
endif
119
122
120
123
" This will not work for a " in the first column...
121
- if s: CurrentChar () == ' "'
124
+ if s: current_char () == ' "'
122
125
call cursor (0 , col (" $" ) - 2 )
123
- if s: SynIdName () !~? " string"
126
+ if s: syn_id_name () !~? " string"
124
127
return -1
125
128
endif
126
- if s: CurrentChar () != ' \\'
129
+ if s: current_char () != ' \\'
127
130
return -1
128
131
endif
129
132
call cursor (0 , col (" $" ) - 1 )
@@ -138,51 +141,51 @@ if exists("*searchpairpos")
138
141
return indent (" ." )
139
142
endfunction
140
143
141
- function ! s: CheckForString ()
144
+ function ! s: check_for_string ()
142
145
let pos = getpos (' .' )
143
146
try
144
- let val = s: ClojureCheckForStringWorker ()
147
+ let val = s: clojure_check_for_string_worker ()
145
148
finally
146
149
call setpos (' .' , pos)
147
150
endtry
148
151
return val
149
152
endfunction
150
153
151
- function ! s: StripNamespaceAndMacroChars (word)
154
+ function ! s: strip_namespace_and_macro_chars (word)
152
155
return substitute (a: word , " \\ v%(.*/|[#'`~@^,]*)(.*)" , ' \1' , ' ' )
153
156
endfunction
154
157
155
- function ! s: ClojureIsMethodSpecialCaseWorker (position)
158
+ function ! s: clojure_is_method_special_case_worker (position)
156
159
" Find the next enclosing form.
157
160
call search (' \S' , ' Wb' )
158
161
159
162
" Special case: we are at a '(('.
160
- if s: CurrentChar () == ' ('
163
+ if s: current_char () == ' ('
161
164
return 0
162
165
endif
163
166
call cursor (a: position )
164
167
165
- let nextParen = s: MatchPairs (' (' , ' )' , 0 )
168
+ let next_paren = s: match_pairs (' (' , ' )' , 0 )
166
169
167
170
" Special case: we are now at toplevel.
168
- if nextParen == [0 , 0 ]
171
+ if next_paren == [0 , 0 ]
169
172
return 0
170
173
endif
171
- call cursor (nextParen )
174
+ call cursor (next_paren )
172
175
173
176
call search (' \S' , ' W' )
174
- let w = s: StripNamespaceAndMacroChars (s: CurrentWord ())
177
+ let w = s: strip_namespace_and_macro_chars (s: current_word ())
175
178
if g: clojure_special_indent_words = ~# ' \V\<' . w . ' \>'
176
179
return 1
177
180
endif
178
181
179
182
return 0
180
183
endfunction
181
184
182
- function ! s: IsMethodSpecialCase (position)
185
+ function ! s: is_method_special_case (position)
183
186
let pos = getpos (' .' )
184
187
try
185
- let val = s: ClojureIsMethodSpecialCaseWorker (a: position )
188
+ let val = s: clojure_is_method_special_case_worker (a: position )
186
189
finally
187
190
call setpos (' .' , pos)
188
191
endtry
@@ -197,7 +200,7 @@ if exists("*searchpairpos")
197
200
198
201
" We have to apply some heuristics here to figure out, whether to use
199
202
" normal lisp indenting or not.
200
- let i = s: CheckForString ()
203
+ let i = s: check_for_string ()
201
204
if i > -1
202
205
return i + ! ! g: clojure_align_multiline_strings
203
206
endif
@@ -207,9 +210,9 @@ if exists("*searchpairpos")
207
210
" Find the next enclosing [ or {. We can limit the second search
208
211
" to the line, where the [ was found. If no [ was there this is
209
212
" zero and we search for an enclosing {.
210
- let paren = s: MatchPairs (' (' , ' )' , 0 )
211
- let bracket = s: MatchPairs (' \[' , ' \]' , paren[0 ])
212
- let curly = s: MatchPairs (' {' , ' }' , bracket[0 ])
213
+ let paren = s: match_pairs (' (' , ' )' , 0 )
214
+ let bracket = s: match_pairs (' \[' , ' \]' , paren[0 ])
215
+ let curly = s: match_pairs (' {' , ' }' , bracket[0 ])
213
216
214
217
" In case the curly brace is on a line later then the [ or - in
215
218
" case they are on the same line - in a higher column, we take the
@@ -246,7 +249,7 @@ if exists("*searchpairpos")
246
249
" - In any other case we use the column of the end of the word + 2.
247
250
call cursor (paren)
248
251
249
- if s: IsMethodSpecialCase (paren)
252
+ if s: is_method_special_case (paren)
250
253
return paren[1 ] + &shiftwidth - 1
251
254
endif
252
255
@@ -257,7 +260,7 @@ if exists("*searchpairpos")
257
260
258
261
" In case after the paren is a whitespace, we search for the next word.
259
262
call cursor (0 , col (' .' ) + 1 )
260
- if s: CurrentChar () == ' '
263
+ if s: current_char () == ' '
261
264
call search (' \v\S' , ' W' )
262
265
endif
263
266
@@ -269,7 +272,7 @@ if exists("*searchpairpos")
269
272
270
273
" We still have to check, whether the keyword starts with a (, [ or {.
271
274
" In that case we use the ( position for indent.
272
- let w = s: CurrentWord ()
275
+ let w = s: current_word ()
273
276
if stridx (' ([{' , w [0 ]) > -1
274
277
return paren[1 ]
275
278
endif
@@ -278,15 +281,15 @@ if exists("*searchpairpos")
278
281
" metacharacters.
279
282
"
280
283
" e.g. clojure.core/defn and #'defn should both indent like defn.
281
- let ww = s: StripNamespaceAndMacroChars (w )
284
+ let ww = s: strip_namespace_and_macro_chars (w )
282
285
283
286
if &lispwords = ~# ' \V\<' . ww . ' \>'
284
287
return paren[1 ] + &shiftwidth - 1
285
288
endif
286
289
287
290
if g: clojure_fuzzy_indent
288
- \ && ! s: MatchesOne (g: clojure_fuzzy_indent_blacklist , ww )
289
- \ && s: MatchesOne (g: clojure_fuzzy_indent_patterns , ww )
291
+ \ && ! s: match_one (g: clojure_fuzzy_indent_blacklist , ww )
292
+ \ && s: match_one (g: clojure_fuzzy_indent_patterns , ww )
290
293
return paren[1 ] + &shiftwidth - 1
291
294
endif
292
295
0 commit comments