Skip to content

Commit 6638c13

Browse files
author
Matt Fowles
committed
Update all the formatting
1 parent d62f47b commit 6638c13

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

autoload/codefmt.vim

+14-17
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ function! codefmt#EnsureFormatter(formatter) abort
8484
" Throw BadValue if the wrong number of format functions are provided.
8585
let l:available_format_functions = ['Format', 'FormatRange', 'FormatRanges']
8686
let l:format_functions = filter(copy(l:available_format_functions),
87-
\ 'has_key(a:formatter, v:val)')
87+
\ 'has_key(a:formatter, v:val)')
8888
if empty(l:format_functions)
8989
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, ', '))
9292
endif
9393

9494
" TODO(dbarnett): Check types.
@@ -120,8 +120,7 @@ function! codefmt#GetJsBeautifyFormatter() abort
120120
" {endline}.
121121
" @throws ShellError
122122
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', '-']
125124
if &filetype != ""
126125
let l:cmd = l:cmd + ['--type', &filetype]
127126
endif
@@ -190,8 +189,8 @@ function! codefmt#GetClangFormatFormatter() abort
190189

191190
function l:formatter.AppliesToBuffer() abort
192191
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
195194

196195
""
197196
" Reformat buffer with clang-format, only targeting [ranges] if given.
@@ -244,11 +243,11 @@ function! codefmt#GetClangFormatFormatter() abort
244243
try
245244
let l:clang_format_output_json = maktaba#json#Parse(l:formatted[0])
246245
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
248247
execute 'goto' l:new_cursor_pos
249248
catch
250249
call maktaba#error#Warn('Unable to parse clang-format cursor pos: %s',
251-
\ v:exception)
250+
\ v:exception)
252251
endtry
253252
endif
254253
endfunction
@@ -369,12 +368,10 @@ function! codefmt#GetAutopep8Formatter() abort
369368
let l:lines = getline(1, line('$'))
370369

371370
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, '-']
375372
let l:input = join(l:lines, "\n")
376373
else
377-
let l:cmd = [ l:executable, '-' ]
374+
let l:cmd = [l:executable, '-']
378375
" Hack range formatting by formatting range individually, ignoring context.
379376
let l:input = join(l:lines[a:startline - 1 : a:endline - 1], "\n")
380377
endif
@@ -416,7 +413,7 @@ function! codefmt#IsFormatterAvailable() abort
416413
let l:formatters = copy(s:registry.GetExtensions())
417414
let l:is_available = 'v:val.AppliesToBuffer() && s:IsAvailable(v:val)'
418415
return !empty(filter(l:formatters, l:is_available)) ||
419-
\ !empty(get(b:, 'codefmt_formatter'))
416+
\ !empty(get(b:, 'codefmt_formatter'))
420417
endfunction
421418

422419
function! s:GetSetupInstructions(formatter) abort
@@ -462,13 +459,13 @@ function! s:GetFormatter(...) abort
462459
" Check if we have formatters that are not available for some reason.
463460
" Report a better error message in that case.
464461
let l:unavailable_formatters = filter(
465-
\ copy(l:formatters), 'v:val.AppliesToBuffer()')
462+
\ copy(l:formatters), 'v:val.AppliesToBuffer()')
466463
if !empty(l:unavailable_formatters)
467464
let l:error = join(map(copy(l:unavailable_formatters),
468-
\ 's:GetSetupInstructions(v:val)'), "\n")
465+
\ 's:GetSetupInstructions(v:val)'), "\n")
469466
else
470467
let l:error = 'Not available. codefmt doesn''t have a default ' .
471-
\ 'formatter for this buffer.'
468+
\ 'formatter for this buffer.'
472469
endif
473470
call maktaba#error#Shout(l:error)
474471
return

0 commit comments

Comments
 (0)