File tree 2 files changed +14
-2
lines changed
2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -188,8 +188,13 @@ function! codefmt#GetClangFormatFormatter() abort
188
188
endfunction
189
189
190
190
function l: formatter .AppliesToBuffer () abort
191
- return &filetype is # ' c' || &filetype is # ' cpp' ||
191
+ if &filetype is # ' c' || &filetype is # ' cpp' ||
192
192
\ &filetype is # ' proto' || &filetype is # ' javascript'
193
+ return 1
194
+ endif
195
+ " Version 3.6 adds support for java
196
+ " http://llvm.org/releases/3.6.0/tools/clang/docs/ReleaseNotes.html
197
+ return &filetype is # ' java' && s: ClangFormatHasAtLeastVersion ([3 , 6 ])
193
198
endfunction
194
199
195
200
" "
Original file line number Diff line number Diff line change @@ -76,7 +76,8 @@ You can format any buffer with clang-format specifying the formatter explicitly.
76
76
@end
77
77
78
78
Several filetypes will use the clang-format formatter by default: c, cpp,
79
- javascript, and proto.
79
+ javascript, and proto. If the version of clang-format is >= 3.6, then it will
80
+ also format java files.
80
81
81
82
@clear
82
83
% f();
@@ -99,6 +100,12 @@ javascript, and proto.
99
100
$ { "Cursor": 0 }
100
101
$ f();
101
102
103
+ :set filetype=java
104
+ :FormatCode
105
+ ! clang-format .*
106
+ $ { "Cursor": 0 }
107
+ $ f();
108
+
102
109
:set filetype=
103
110
104
111
It can format specific line ranges of code using :FormatLines.
You can’t perform that action at this time.
0 commit comments