blob: bb7e7cd72cecacc72b562731a08f54b43be96865 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim filetype plugin file
Doug Kearns93197fd2024-01-14 20:59:02 +01002" Language: Java
Bram Moolenaar1588bc82022-03-08 21:35:07 +00003"
4" This runtime file is looking for a new maintainer.
5"
6" Former maintainer: Dan Sharp
Doug Kearns93197fd2024-01-14 20:59:02 +01007" Last Change: 2012 Mar 11
8" 2024 Jan 14 by Vim Project (browsefilter)
Bram Moolenaar071d4272004-06-13 20:20:40 +00009
10if exists("b:did_ftplugin") | finish | endif
11let b:did_ftplugin = 1
12
13" Make sure the continuation lines below do not cause problems in
14" compatibility mode.
15let s:save_cpo = &cpo
16set cpo-=C
17
Bram Moolenaar071d4272004-06-13 20:20:40 +000018" For filename completion, prefer the .java extension over the .class
19" extension.
20set suffixes+=.class
21
22" Enable gf on import statements. Convert . in the package
23" name to / and append .java to the name, then search the path.
24setlocal includeexpr=substitute(v:fname,'\\.','/','g')
25setlocal suffixesadd=.java
26if exists("g:ftplugin_java_source_path")
27 let &l:path=g:ftplugin_java_source_path . ',' . &l:path
28endif
29
30" Set 'formatoptions' to break comment lines but not other lines,
31" and insert the comment leader when hitting <CR> or using "o".
32setlocal formatoptions-=t formatoptions+=croql
33
34" Set 'comments' to format dashed lists in comments. Behaves just like C.
35setlocal comments& comments^=sO:*\ -,mO:*\ \ ,exO:*/
36
37setlocal commentstring=//%s
38
39" Change the :browse e filter to primarily show Java-related files.
Doug Kearns93197fd2024-01-14 20:59:02 +010040if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
Bram Moolenaar071d4272004-06-13 20:20:40 +000041 let b:browsefilter="Java Files (*.java)\t*.java\n" .
42 \ "Properties Files (*.prop*)\t*.prop*\n" .
Doug Kearns93197fd2024-01-14 20:59:02 +010043 \ "Manifest Files (*.mf)\t*.mf\n"
44 if has("win32")
45 let b:browsefilter .= "All Files (*.*)\t*\n"
46 else
47 let b:browsefilter .= "All Files (*)\t*\n"
48 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000049endif
50
51" Undo the stuff we changed.
Bram Moolenaar8b879e72005-03-28 20:49:18 +000052let b:undo_ftplugin = "setlocal suffixes< suffixesadd<" .
Bram Moolenaar071d4272004-06-13 20:20:40 +000053 \ " formatoptions< comments< commentstring< path< includeexpr<" .
54 \ " | unlet! b:browsefilter"
55
56" Restore the saved compatibility options.
57let &cpo = s:save_cpo
Bram Moolenaar84f72352012-03-11 15:57:40 +010058unlet s:save_cpo