Skip to content

Commit ed2ebdb

Browse files
committed
mark all functions as 'abort'
1 parent f759745 commit ed2ebdb

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

autoload/clang_format.vim

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set cpo&vim
44
let s:on_windows = has('win32') || has('win64')
55

66
" helper functions {{{
7-
function! s:has_vimproc()
7+
function! s:has_vimproc() abort
88
if !exists('s:exists_vimproc')
99
try
1010
silent call vimproc#version()
@@ -16,7 +16,7 @@ function! s:has_vimproc()
1616
return s:exists_vimproc
1717
endfunction
1818

19-
function! s:system(str, ...)
19+
function! s:system(str, ...) abort
2020
let command = a:str
2121
let input = a:0 >= 1 ? a:1 : ''
2222

@@ -49,7 +49,7 @@ function! s:stringize_options(opts) abort
4949
return join(keyvals, ',')
5050
endfunction
5151

52-
function! s:build_extra_options()
52+
function! s:build_extra_options() abort
5353
let extra_options = ''
5454

5555
let opts = copy(g:clang_format#style_options)
@@ -62,7 +62,7 @@ function! s:build_extra_options()
6262
return extra_options
6363
endfunction
6464

65-
function! s:make_style_options()
65+
function! s:make_style_options() abort
6666
let extra_options = s:build_extra_options()
6767
return printf("'{BasedOnStyle: %s, IndentWidth: %d, UseTab: %s%s}'",
6868
\ g:clang_format#code_style,
@@ -71,12 +71,12 @@ function! s:make_style_options()
7171
\ extra_options)
7272
endfunction
7373

74-
function! s:success(result)
74+
function! s:success(result) abort
7575
return (s:has_vimproc() ? vimproc#get_last_status() : v:shell_error) == 0
7676
\ && a:result !~# '^YAML:\d\+:\d\+: error: unknown key '
7777
endfunction
7878

79-
function! s:error_message(result)
79+
function! s:error_message(result) abort
8080
echoerr 'clang-format has failed to format.'
8181
if a:result =~# '^YAML:\d\+:\d\+: error: unknown key '
8282
echohl ErrorMsg
@@ -101,7 +101,7 @@ function! s:restore_screen_pos(prev_screen) abort
101101
execute "normal!" keys
102102
endfunction
103103

104-
function! clang_format#get_version()
104+
function! clang_format#get_version() abort
105105
if &shell =~# 'csh$' && executable('/bin/bash')
106106
let shell_save = &shell
107107
set shell=/bin/bash
@@ -122,7 +122,7 @@ function! clang_format#get_version()
122122
endtry
123123
endfunction
124124

125-
function! clang_format#is_invalid()
125+
function! clang_format#is_invalid() abort
126126
if !exists('s:command_available')
127127
if !executable(g:clang_format#command)
128128
return 1
@@ -145,7 +145,7 @@ function! clang_format#is_invalid()
145145
return 0
146146
endfunction
147147

148-
function! s:verify_command()
148+
function! s:verify_command() abort
149149
let invalidity = clang_format#is_invalid()
150150
if invalidity == 1
151151
echoerr "clang-format is not found. check g:clang_format#command."
@@ -167,7 +167,7 @@ endfunction
167167
" }}}
168168

169169
" variable definitions {{{
170-
function! s:getg(name, default)
170+
function! s:getg(name, default) abort
171171
" backward compatibility
172172
if exists('g:operator_'.substitute(a:name, '#', '_', ''))
173173
echoerr 'g:operator_'.substitute(a:name, '#', '_', '').' is deprecated. Please use g:'.a:name
@@ -194,12 +194,12 @@ let g:clang_format#auto_formatexpr = s:getg('clang_format#auto_formatexpr', 0)
194194
" }}}
195195

196196
" format codes {{{
197-
function! s:detect_style_file()
197+
function! s:detect_style_file() abort
198198
let dirname = fnameescape(expand('%:p:h'))
199199
return findfile('.clang-format', dirname.';') != '' || findfile('_clang-format', dirname.';') != ''
200200
endfunction
201201

202-
function! clang_format#format(line1, line2)
202+
function! clang_format#format(line1, line2) abort
203203
let args = printf(' -lines=%d:%d', a:line1, a:line2)
204204
if ! (g:clang_format#detect_style_file && s:detect_style_file())
205205
let args .= printf(' -style=%s ', s:make_style_options())
@@ -217,7 +217,7 @@ endfunction
217217
" }}}
218218

219219
" replace buffer {{{
220-
function! clang_format#replace(line1, line2)
220+
function! clang_format#replace(line1, line2) abort
221221

222222
call s:verify_command()
223223

@@ -249,7 +249,7 @@ endfunction
249249
" auto formatting on insert leave {{{
250250
let s:pos_on_insertenter = []
251251

252-
function! s:format_inserted_area()
252+
function! s:format_inserted_area() abort
253253
let pos = getpos('.')
254254
" When in the same buffer
255255
if &modified && ! empty(s:pos_on_insertenter) && s:pos_on_insertenter[0] == pos[0]
@@ -258,7 +258,7 @@ function! s:format_inserted_area()
258258
endif
259259
endfunction
260260

261-
function! clang_format#enable_format_on_insert()
261+
function! clang_format#enable_format_on_insert() abort
262262
augroup plugin-clang-format-auto-format-insert
263263
autocmd!
264264
autocmd InsertEnter <buffer> let s:pos_on_insertenter = getpos('.')
@@ -268,7 +268,7 @@ endfunction
268268
" }}}
269269

270270
" toggle auto formatting {{{
271-
function! clang_format#toggle_auto_format()
271+
function! clang_format#toggle_auto_format() abort
272272
let g:clang_format#auto_format = !g:clang_format#auto_format
273273
if g:clang_format#auto_format
274274
echo 'Auto clang-format: enabled'
@@ -279,13 +279,13 @@ endfunction
279279
" }}}
280280

281281
" enable auto formatting {{{
282-
function! clang_format#enable_auto_format()
282+
function! clang_format#enable_auto_format() abort
283283
let g:clang_format#auto_format = 1
284284
endfunction
285285
" }}}
286286

287287
" disable auto formatting {{{
288-
function! clang_format#disable_auto_format()
288+
function! clang_format#disable_auto_format() abort
289289
let g:clang_format#auto_format = 0
290290
endfunction
291291
" }}}

autoload/operator/clang_format.vim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
function! s:is_empty_region(begin, end)
1+
function! s:is_empty_region(begin, end) abort
22
return a:begin[1] > a:end[1] || (a:begin[1] == a:end[1] && a:end[2] < a:begin[2])
33
endfunction
44

5-
function! s:restore_screen_pos()
5+
function! s:restore_screen_pos() abort
66
let line_diff = line('w0') - g:operator#clang_format#save_screen_pos
77
if line_diff > 0
88
execute 'silent normal!' line_diff."\<C-y>"
@@ -11,7 +11,7 @@ function! s:restore_screen_pos()
1111
endif
1212
endfunction
1313

14-
function! operator#clang_format#do(motion_wise)
14+
function! operator#clang_format#do(motion_wise) abort
1515
if s:is_empty_region(getpos("'["), getpos("']"))
1616
return
1717
endif

t/clang_format_spec.vim

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
" helpers "{{{
55
" clang-format detection
6-
function! s:detect_clang_format()
6+
function! s:detect_clang_format() abort
77
if $CLANG_FORMAT !=# '' && executable($CLANG_FORMAT)
88
return $CLANG_FORMAT
99
endif
@@ -18,23 +18,23 @@ function! s:detect_clang_format()
1818
endfunction
1919
let g:clang_format#command = s:detect_clang_format()
2020

21-
function! Chomp(s)
21+
function! Chomp(s) abort
2222
return a:s =~# '\n$'
2323
\ ? a:s[0:len(a:s)-2]
2424
\ : a:s
2525
endfunction
2626

27-
function! ChompHead(s)
27+
function! ChompHead(s) abort
2828
return a:s =~# '^\n'
2929
\ ? a:s[1:len(a:s)-1]
3030
\ : a:s
3131
endfunction
3232

33-
function! GetBuffer()
33+
function! GetBuffer() abort
3434
return join(getline(1, '$'), "\n")
3535
endfunction
3636

37-
function! ClangFormat(line1, line2, ...)
37+
function! ClangFormat(line1, line2, ...) abort
3838
let opt = printf("-lines=%d:%d -style='{BasedOnStyle: Google, IndentWidth: %d, UseTab: %s", a:line1, a:line2, &l:shiftwidth, &l:expandtab==1 ? "false" : "true")
3939
let file = 'test.cpp'
4040

@@ -65,7 +65,7 @@ runtime! plugin/clang_format.vim
6565

6666
call vspec#customize_matcher('to_be_empty', function('empty'))
6767

68-
function! RaisesException(cmd)
68+
function! RaisesException(cmd) abort
6969
try
7070
execute a:cmd
7171
return 0
@@ -118,7 +118,7 @@ end
118118
"}}}
119119

120120
" test for clang_format#format() {{{
121-
function! s:expect_the_same_output(line1, line2)
121+
function! s:expect_the_same_output(line1, line2) abort
122122
Expect clang_format#format(a:line1, a:line2) ==# ClangFormat(a:line1, a:line2)
123123
endfunction
124124

0 commit comments

Comments
 (0)