Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim filetype plugin file |
| 2 | " Language: Java |
| 3 | " Maintainer: Dan Sharp <dwsharp at hotmail dot com> |
| 4 | " Last Change: 2004 May 16 |
| 5 | " URL: http://mywebpage.netscape.com/sharppeople/vim/ftplugin |
| 6 | |
| 7 | if exists("b:did_ftplugin") | finish | endif |
| 8 | let b:did_ftplugin = 1 |
| 9 | |
| 10 | " Make sure the continuation lines below do not cause problems in |
| 11 | " compatibility mode. |
| 12 | let s:save_cpo = &cpo |
| 13 | set cpo-=C |
| 14 | |
| 15 | " Go ahead and set this to get decent indenting even if the indent files |
| 16 | " aren't being used. For people who really don't want any indentation, |
| 17 | " let them turn it off. |
| 18 | if !exists("g:ftplugin_java_no_indent") |
| 19 | setlocal cindent |
| 20 | |
| 21 | "--------------------- |
| 22 | " Correctly indent anonymous classes |
| 23 | " From Johannes Zellner <johannes@zellner.org> |
| 24 | setlocal cinoptions+=j1 |
| 25 | "--------------------- |
| 26 | endif |
| 27 | |
| 28 | " For filename completion, prefer the .java extension over the .class |
| 29 | " extension. |
| 30 | set suffixes+=.class |
| 31 | |
| 32 | " Enable gf on import statements. Convert . in the package |
| 33 | " name to / and append .java to the name, then search the path. |
| 34 | setlocal includeexpr=substitute(v:fname,'\\.','/','g') |
| 35 | setlocal suffixesadd=.java |
| 36 | if exists("g:ftplugin_java_source_path") |
| 37 | let &l:path=g:ftplugin_java_source_path . ',' . &l:path |
| 38 | endif |
| 39 | |
| 40 | " Set 'formatoptions' to break comment lines but not other lines, |
| 41 | " and insert the comment leader when hitting <CR> or using "o". |
| 42 | setlocal formatoptions-=t formatoptions+=croql |
| 43 | |
| 44 | " Set 'comments' to format dashed lists in comments. Behaves just like C. |
| 45 | setlocal comments& comments^=sO:*\ -,mO:*\ \ ,exO:*/ |
| 46 | |
| 47 | setlocal commentstring=//%s |
| 48 | |
| 49 | " Change the :browse e filter to primarily show Java-related files. |
| 50 | if has("gui_win32") |
| 51 | let b:browsefilter="Java Files (*.java)\t*.java\n" . |
| 52 | \ "Properties Files (*.prop*)\t*.prop*\n" . |
| 53 | \ "Manifest Files (*.mf)\t*.mf\n" . |
| 54 | \ "All Files (*.*)\t*.*\n" |
| 55 | endif |
| 56 | |
| 57 | " Undo the stuff we changed. |
| 58 | let b:undo_ftplugin = "setlocal cindent< cinoptions< suffixes< suffixesadd<" . |
| 59 | \ " formatoptions< comments< commentstring< path< includeexpr<" . |
| 60 | \ " | unlet! b:browsefilter" |
| 61 | |
| 62 | " Restore the saved compatibility options. |
| 63 | let &cpo = s:save_cpo |