@@ -84,11 +84,11 @@ function! codefmt#EnsureFormatter(formatter) abort
84
84
" Throw BadValue if the wrong number of format functions are provided.
85
85
let l: available_format_functions = [' Format' , ' FormatRange' , ' FormatRanges' ]
86
86
let l: format_functions = filter (copy (l: available_format_functions ),
87
- \ ' has_key(a:formatter, v:val)' )
87
+ \ ' has_key(a:formatter, v:val)' )
88
88
if empty (l: format_functions )
89
89
throw maktaba#error#BadValue (' Formatter ' . a: formatter .name .
90
- \ ' has no format functions. It must have at least one of ' .
91
- \ join (l: available_format_functions , ' , ' ))
90
+ \ ' has no format functions. It must have at least one of ' .
91
+ \ join (l: available_format_functions , ' , ' ))
92
92
endif
93
93
94
94
" TODO(dbarnett): Check types.
@@ -120,8 +120,7 @@ function! codefmt#GetJsBeautifyFormatter() abort
120
120
" {endline}.
121
121
" @throws ShellError
122
122
function l: formatter .FormatRange (startline, endline) abort
123
- let l: cmd = [ s: plugin .Flag (' js_beautify_executable' ),
124
- \' - f ' , ' - ' ]
123
+ let l: cmd = [s: plugin .Flag (' js_beautify_executable' ), ' -f' , ' -' ]
125
124
if &filetype != " "
126
125
let l: cmd = l: cmd + [' --type' , &filetype ]
127
126
endif
@@ -190,8 +189,8 @@ function! codefmt#GetClangFormatFormatter() abort
190
189
191
190
function l: formatter .AppliesToBuffer () abort
192
191
return &filetype is # ' c' || &filetype is # ' cpp' ||
193
- \ &filetype is # ' proto' || &filetype is # ' javascript'
194
- endfunction :
192
+ \ &filetype is # ' proto' || &filetype is # ' javascript'
193
+ endfunction
195
194
196
195
" "
197
196
" Reformat buffer with clang-format, only targeting [ranges] if given.
@@ -244,11 +243,11 @@ function! codefmt#GetClangFormatFormatter() abort
244
243
try
245
244
let l: clang_format_output_json = maktaba#json#Parse (l: formatted [0 ])
246
245
let l: new_cursor_pos =
247
- \ maktaba#ensure#IsNumber (l: clang_format_output_json .Cursor ) + 1
246
+ \ maktaba#ensure#IsNumber (l: clang_format_output_json .Cursor ) + 1
248
247
execute ' goto' l: new_cursor_pos
249
248
catch
250
249
call maktaba#error#Warn (' Unable to parse clang-format cursor pos: %s' ,
251
- \ v: exception )
250
+ \ v: exception )
252
251
endtry
253
252
endif
254
253
endfunction
@@ -369,12 +368,10 @@ function! codefmt#GetAutopep8Formatter() abort
369
368
let l: lines = getline (1 , line (' $' ))
370
369
371
370
if s: autopep8_supports_range
372
- let l: cmd = [ l: executable ,
373
- \ ' --range' , ' ' .a: startline , ' ' .a: endline ,
374
- \ ' -' ]
371
+ let l: cmd = [l: executable , ' --range' , ' ' .a: startline , ' ' .a: endline , ' -' ]
375
372
let l: input = join (l: lines , " \n " )
376
373
else
377
- let l: cmd = [ l: executable , ' -' ]
374
+ let l: cmd = [l: executable , ' -' ]
378
375
" Hack range formatting by formatting range individually, ignoring context.
379
376
let l: input = join (l: lines [a: startline - 1 : a: endline - 1 ], " \n " )
380
377
endif
@@ -416,7 +413,7 @@ function! codefmt#IsFormatterAvailable() abort
416
413
let l: formatters = copy (s: registry .GetExtensions ())
417
414
let l: is_available = ' v:val.AppliesToBuffer() && s:IsAvailable(v:val)'
418
415
return ! empty (filter (l: formatters , l: is_available )) ||
419
- \ ! empty (get (b: , ' codefmt_formatter' ))
416
+ \ ! empty (get (b: , ' codefmt_formatter' ))
420
417
endfunction
421
418
422
419
function ! s: GetSetupInstructions (formatter) abort
@@ -462,13 +459,13 @@ function! s:GetFormatter(...) abort
462
459
" Check if we have formatters that are not available for some reason.
463
460
" Report a better error message in that case.
464
461
let l: unavailable_formatters = filter (
465
- \ copy (l: formatters ), ' v:val.AppliesToBuffer()' )
462
+ \ copy (l: formatters ), ' v:val.AppliesToBuffer()' )
466
463
if ! empty (l: unavailable_formatters )
467
464
let l: error = join (map (copy (l: unavailable_formatters ),
468
- \ ' s:GetSetupInstructions(v:val)' ), " \n " )
465
+ \ ' s:GetSetupInstructions(v:val)' ), " \n " )
469
466
else
470
467
let l: error = ' Not available. codefmt doesn'' t have a default ' .
471
- \ ' formatter for this buffer.'
468
+ \ ' formatter for this buffer.'
472
469
endif
473
470
call maktaba#error#Shout (l: error )
474
471
return
0 commit comments