@@ -4,7 +4,7 @@ set cpo&vim
44let 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
1717endfunction
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, ' ,' )
5050endfunction
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
6363endfunction
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)
7272endfunction
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 '
7777endfunction
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
102102endfunction
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
123123endfunction
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
146146endfunction
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.' ;' ) != ' '
200200endfunction
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 {{{
250250let 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
259259endfunction
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
284284endfunction
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
290290endfunction
291291" }}}
0 commit comments