Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim filetype plugin file |
| 2 | " Language: Java |
Bram Moolenaar | 1588bc8 | 2022-03-08 21:35:07 +0000 | [diff] [blame] | 3 | " |
| 4 | " This runtime file is looking for a new maintainer. |
| 5 | " |
| 6 | " Former maintainer: Dan Sharp |
Bram Moolenaar | 84f7235 | 2012-03-11 15:57:40 +0100 | [diff] [blame] | 7 | " Last Change: 2012 Mar 11 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8 | |
| 9 | if exists("b:did_ftplugin") | finish | endif |
| 10 | let b:did_ftplugin = 1 |
| 11 | |
| 12 | " Make sure the continuation lines below do not cause problems in |
| 13 | " compatibility mode. |
| 14 | let s:save_cpo = &cpo |
| 15 | set cpo-=C |
| 16 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 17 | " For filename completion, prefer the .java extension over the .class |
| 18 | " extension. |
| 19 | set suffixes+=.class |
| 20 | |
| 21 | " Enable gf on import statements. Convert . in the package |
| 22 | " name to / and append .java to the name, then search the path. |
| 23 | setlocal includeexpr=substitute(v:fname,'\\.','/','g') |
| 24 | setlocal suffixesadd=.java |
| 25 | if exists("g:ftplugin_java_source_path") |
| 26 | let &l:path=g:ftplugin_java_source_path . ',' . &l:path |
| 27 | endif |
| 28 | |
| 29 | " Set 'formatoptions' to break comment lines but not other lines, |
| 30 | " and insert the comment leader when hitting <CR> or using "o". |
| 31 | setlocal formatoptions-=t formatoptions+=croql |
| 32 | |
| 33 | " Set 'comments' to format dashed lists in comments. Behaves just like C. |
| 34 | setlocal comments& comments^=sO:*\ -,mO:*\ \ ,exO:*/ |
| 35 | |
| 36 | setlocal commentstring=//%s |
| 37 | |
| 38 | " Change the :browse e filter to primarily show Java-related files. |
| 39 | if has("gui_win32") |
| 40 | let b:browsefilter="Java Files (*.java)\t*.java\n" . |
| 41 | \ "Properties Files (*.prop*)\t*.prop*\n" . |
| 42 | \ "Manifest Files (*.mf)\t*.mf\n" . |
| 43 | \ "All Files (*.*)\t*.*\n" |
| 44 | endif |
| 45 | |
| 46 | " Undo the stuff we changed. |
Bram Moolenaar | 8b879e7 | 2005-03-28 20:49:18 +0000 | [diff] [blame] | 47 | let b:undo_ftplugin = "setlocal suffixes< suffixesadd<" . |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 48 | \ " formatoptions< comments< commentstring< path< includeexpr<" . |
| 49 | \ " | unlet! b:browsefilter" |
| 50 | |
| 51 | " Restore the saved compatibility options. |
| 52 | let &cpo = s:save_cpo |
Bram Moolenaar | 84f7235 | 2012-03-11 15:57:40 +0100 | [diff] [blame] | 53 | unlet s:save_cpo |