@@ -4,7 +4,7 @@ set cpo&vim
4
4
let s: on_windows = has (' win32' ) || has (' win64' )
5
5
6
6
" helper functions {{{
7
- function ! s: has_vimproc ()
7
+ function ! s: has_vimproc () abort
8
8
if ! exists (' s:exists_vimproc' )
9
9
try
10
10
silent call vimproc#version ()
@@ -16,7 +16,7 @@ function! s:has_vimproc()
16
16
return s: exists_vimproc
17
17
endfunction
18
18
19
- function ! s: system (str, ... )
19
+ function ! s: system (str, ... ) abort
20
20
let command = a: str
21
21
let input = a: 0 >= 1 ? a: 1 : ' '
22
22
@@ -49,7 +49,7 @@ function! s:stringize_options(opts) abort
49
49
return join (keyvals, ' ,' )
50
50
endfunction
51
51
52
- function ! s: build_extra_options ()
52
+ function ! s: build_extra_options () abort
53
53
let extra_options = ' '
54
54
55
55
let opts = copy (g: clang_format #style_options)
@@ -62,7 +62,7 @@ function! s:build_extra_options()
62
62
return extra_options
63
63
endfunction
64
64
65
- function ! s: make_style_options ()
65
+ function ! s: make_style_options () abort
66
66
let extra_options = s: build_extra_options ()
67
67
return printf (" '{BasedOnStyle: %s, IndentWidth: %d, UseTab: %s%s}'" ,
68
68
\ g: clang_format #code_style,
@@ -71,12 +71,12 @@ function! s:make_style_options()
71
71
\ extra_options)
72
72
endfunction
73
73
74
- function ! s: success (result)
74
+ function ! s: success (result) abort
75
75
return (s: has_vimproc () ? vimproc#get_last_status () : v: shell_error ) == 0
76
76
\ && a: result !~# ' ^YAML:\d\+:\d\+: error: unknown key '
77
77
endfunction
78
78
79
- function ! s: error_message (result)
79
+ function ! s: error_message (result) abort
80
80
echoerr ' clang-format has failed to format.'
81
81
if a: result = ~# ' ^YAML:\d\+:\d\+: error: unknown key '
82
82
echohl ErrorMsg
@@ -101,7 +101,7 @@ function! s:restore_screen_pos(prev_screen) abort
101
101
execute " normal!" keys
102
102
endfunction
103
103
104
- function ! clang_format#get_version ()
104
+ function ! clang_format#get_version () abort
105
105
if &shell = ~# ' csh$' && executable (' /bin/bash' )
106
106
let shell_save = &shell
107
107
set shell = /bin/ bash
@@ -122,7 +122,7 @@ function! clang_format#get_version()
122
122
endtry
123
123
endfunction
124
124
125
- function ! clang_format#is_invalid ()
125
+ function ! clang_format#is_invalid () abort
126
126
if ! exists (' s:command_available' )
127
127
if ! executable (g: clang_format #command )
128
128
return 1
@@ -145,7 +145,7 @@ function! clang_format#is_invalid()
145
145
return 0
146
146
endfunction
147
147
148
- function ! s: verify_command ()
148
+ function ! s: verify_command () abort
149
149
let invalidity = clang_format#is_invalid ()
150
150
if invalidity == 1
151
151
echoerr " clang-format is not found. check g:clang_format#command."
@@ -167,7 +167,7 @@ endfunction
167
167
" }}}
168
168
169
169
" variable definitions {{{
170
- function ! s: getg (name, default)
170
+ function ! s: getg (name, default) abort
171
171
" backward compatibility
172
172
if exists (' g:operator_' .substitute (a: name , ' #' , ' _' , ' ' ))
173
173
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)
194
194
" }}}
195
195
196
196
" format codes {{{
197
- function ! s: detect_style_file ()
197
+ function ! s: detect_style_file () abort
198
198
let dirname = fnameescape (expand (' %:p:h' ))
199
199
return findfile (' .clang-format' , dirname.' ;' ) != ' ' || findfile (' _clang-format' , dirname.' ;' ) != ' '
200
200
endfunction
201
201
202
- function ! clang_format#format (line1, line2)
202
+ function ! clang_format#format (line1, line2) abort
203
203
let args = printf (' -lines=%d:%d' , a: line1 , a: line2 )
204
204
if ! (g: clang_format #detect_style_file && s: detect_style_file ())
205
205
let args .= printf (' -style=%s ' , s: make_style_options ())
@@ -217,7 +217,7 @@ endfunction
217
217
" }}}
218
218
219
219
" replace buffer {{{
220
- function ! clang_format#replace (line1, line2)
220
+ function ! clang_format#replace (line1, line2) abort
221
221
222
222
call s: verify_command ()
223
223
@@ -249,7 +249,7 @@ endfunction
249
249
" auto formatting on insert leave {{{
250
250
let s: pos_on_insertenter = []
251
251
252
- function ! s: format_inserted_area ()
252
+ function ! s: format_inserted_area () abort
253
253
let pos = getpos (' .' )
254
254
" When in the same buffer
255
255
if &modified && ! empty (s: pos_on_insertenter ) && s: pos_on_insertenter [0 ] == pos[0 ]
@@ -258,7 +258,7 @@ function! s:format_inserted_area()
258
258
endif
259
259
endfunction
260
260
261
- function ! clang_format#enable_format_on_insert ()
261
+ function ! clang_format#enable_format_on_insert () abort
262
262
augroup plugin - clang- format- auto- format- insert
263
263
autocmd !
264
264
autocmd InsertEnter <buffer> let s: pos_on_insertenter = getpos (' .' )
@@ -268,7 +268,7 @@ endfunction
268
268
" }}}
269
269
270
270
" toggle auto formatting {{{
271
- function ! clang_format#toggle_auto_format ()
271
+ function ! clang_format#toggle_auto_format () abort
272
272
let g: clang_format #auto_format = ! g: clang_format #auto_format
273
273
if g: clang_format #auto_format
274
274
echo ' Auto clang-format: enabled'
@@ -279,13 +279,13 @@ endfunction
279
279
" }}}
280
280
281
281
" enable auto formatting {{{
282
- function ! clang_format#enable_auto_format ()
282
+ function ! clang_format#enable_auto_format () abort
283
283
let g: clang_format #auto_format = 1
284
284
endfunction
285
285
" }}}
286
286
287
287
" disable auto formatting {{{
288
- function ! clang_format#disable_auto_format ()
288
+ function ! clang_format#disable_auto_format () abort
289
289
let g: clang_format #auto_format = 0
290
290
endfunction
291
291
" }}}
0 commit comments