blob: 292cb6b16600770fa6d7e63db69871b9ffb05c40 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim filetype plugin file
2" Language: Java
Bram Moolenaar5c736222010-01-06 20:54:52 +01003" Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net>
Bram Moolenaar84f72352012-03-11 15:57:40 +01004" Last Change: 2012 Mar 11
Bram Moolenaar5c736222010-01-06 20:54:52 +01005" URL: http://dwsharp.users.sourceforge.net/vim/ftplugin
Bram Moolenaar071d4272004-06-13 20:20:40 +00006
7if exists("b:did_ftplugin") | finish | endif
8let b:did_ftplugin = 1
9
10" Make sure the continuation lines below do not cause problems in
11" compatibility mode.
12let s:save_cpo = &cpo
13set cpo-=C
14
Bram Moolenaar071d4272004-06-13 20:20:40 +000015" For filename completion, prefer the .java extension over the .class
16" extension.
17set suffixes+=.class
18
19" Enable gf on import statements. Convert . in the package
20" name to / and append .java to the name, then search the path.
21setlocal includeexpr=substitute(v:fname,'\\.','/','g')
22setlocal suffixesadd=.java
23if exists("g:ftplugin_java_source_path")
24 let &l:path=g:ftplugin_java_source_path . ',' . &l:path
25endif
26
27" Set 'formatoptions' to break comment lines but not other lines,
28" and insert the comment leader when hitting <CR> or using "o".
29setlocal formatoptions-=t formatoptions+=croql
30
31" Set 'comments' to format dashed lists in comments. Behaves just like C.
32setlocal comments& comments^=sO:*\ -,mO:*\ \ ,exO:*/
33
34setlocal commentstring=//%s
35
36" Change the :browse e filter to primarily show Java-related files.
37if has("gui_win32")
38 let b:browsefilter="Java Files (*.java)\t*.java\n" .
39 \ "Properties Files (*.prop*)\t*.prop*\n" .
40 \ "Manifest Files (*.mf)\t*.mf\n" .
41 \ "All Files (*.*)\t*.*\n"
42endif
43
44" Undo the stuff we changed.
Bram Moolenaar8b879e72005-03-28 20:49:18 +000045let b:undo_ftplugin = "setlocal suffixes< suffixesadd<" .
Bram Moolenaar071d4272004-06-13 20:20:40 +000046 \ " formatoptions< comments< commentstring< path< includeexpr<" .
47 \ " | unlet! b:browsefilter"
48
49" Restore the saved compatibility options.
50let &cpo = s:save_cpo
Bram Moolenaar84f72352012-03-11 15:57:40 +010051unlet s:save_cpo