File tree Expand file tree Collapse file tree 2 files changed +10
-16
lines changed Expand file tree Collapse file tree 2 files changed +10
-16
lines changed Original file line number Diff line number Diff line change @@ -76,32 +76,23 @@ function! clang_format#get_version()
76
76
endtry
77
77
endfunction
78
78
79
- function ! clang_format#is_invalid ()
79
+ function ! clang_format#check_cmd ()
80
80
if ! exists (' s:command_available' )
81
81
if ! executable (g: clang_format #command )
82
- return 1
82
+ return ' clang-format is not found. check g:clang_format#command. '
83
83
endif
84
84
let s: command_available = 1
85
85
endif
86
86
87
87
if ! exists (' s:version' )
88
88
let v = clang_format#get_version ()
89
89
if v [0 ] < 3 || (v [0 ] == 3 && v [1 ] < 4 )
90
- return 2
90
+ return ' clang-format 3.3 or earlier is not supported for the lack of aruguments. '
91
91
endif
92
92
let s: version = v
93
93
endif
94
94
95
- return 0
96
- endfunction
97
-
98
- function ! s: verify_command ()
99
- let invalidity = clang_format#is_invalid ()
100
- if invalidity == 1
101
- echoerr " clang-format is not found. check g:clang_format#command."
102
- elseif invalidity == 2
103
- echoerr ' clang-format 3.3 or earlier is not supported for the lack of aruguments'
104
- endif
95
+ return ' '
105
96
endfunction
106
97
" }}}
107
98
@@ -153,7 +144,10 @@ endfunction
153
144
" replace buffer {{{
154
145
function ! clang_format#replace (line1, line2)
155
146
156
- call s: verify_command ()
147
+ let err_msg = clang_format#check_cmd ()
148
+ if err_msg !=# ' '
149
+ echoerr err_msg
150
+ endif
157
151
158
152
let pos_save = getpos (' .' )
159
153
let sel_save = &l: selection
Original file line number Diff line number Diff line change @@ -14,8 +14,8 @@ command! -range=% -nargs=0 ClangFormatEchoFormattedCode echo clang_format#format
14
14
15
15
augroup plugin - clang- format- auto- format
16
16
autocmd !
17
- autocmd BufWritePre * if &ft = ~# ' ^\%(c\|cpp\|objc\)$' && g: clang_format #auto_format && ! clang_format#is_invalid () | call clang_format#replace (1 , line (' $' )) | endif
18
- autocmd FileType c,cpp,objc if g: clang_format #auto_format_on_insert_leave && ! clang_format#is_invalid () | call clang_format#enable_format_on_insert () | endif
17
+ autocmd BufWritePre * if &ft = ~# ' ^\%(c\|cpp\|objc\)$' && g: clang_format #auto_format && clang_format#check_cmd () == # ' ' | call clang_format#replace (1 , line (' $' )) | endif
18
+ autocmd FileType c,cpp,objc if g: clang_format #auto_format_on_insert_leave && clang_format#check_cmd () == # ' ' | call clang_format#enable_format_on_insert () | endif
19
19
augroup END
20
20
21
21
let g: loaded_clang_format = 1
You can’t perform that action at this time.
0 commit comments