Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim filetype plugin file |
Doug Kearns | 93197fd | 2024-01-14 20:59:02 +0100 | [diff] [blame] | 2 | " Language: Java |
Aliaksei Budavei | 4052474 | 2024-04-14 19:57:00 +0300 | [diff] [blame] | 3 | " Maintainer: Aliaksei Budavei <0x000c70 AT gmail DOT com> |
| 4 | " Former Maintainer: Dan Sharp |
| 5 | " Repository: https://github.com/zzzyxwvut/java-vim.git |
| 6 | " Last Change: 2024 Apr 13 |
Doug Kearns | 93197fd | 2024-01-14 20:59:02 +0100 | [diff] [blame] | 7 | " 2024 Jan 14 by Vim Project (browsefilter) |
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. |
Doug Kearns | 93197fd | 2024-01-14 20:59:02 +0100 | [diff] [blame] | 39 | if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 40 | let b:browsefilter="Java Files (*.java)\t*.java\n" . |
| 41 | \ "Properties Files (*.prop*)\t*.prop*\n" . |
Doug Kearns | 93197fd | 2024-01-14 20:59:02 +0100 | [diff] [blame] | 42 | \ "Manifest Files (*.mf)\t*.mf\n" |
| 43 | if has("win32") |
| 44 | let b:browsefilter .= "All Files (*.*)\t*\n" |
| 45 | else |
| 46 | let b:browsefilter .= "All Files (*)\t*\n" |
| 47 | endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 48 | endif |
| 49 | |
| 50 | " Undo the stuff we changed. |
Bram Moolenaar | 8b879e7 | 2005-03-28 20:49:18 +0000 | [diff] [blame] | 51 | let b:undo_ftplugin = "setlocal suffixes< suffixesadd<" . |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 52 | \ " formatoptions< comments< commentstring< path< includeexpr<" . |
| 53 | \ " | unlet! b:browsefilter" |
| 54 | |
| 55 | " Restore the saved compatibility options. |
| 56 | let &cpo = s:save_cpo |
Bram Moolenaar | 84f7235 | 2012-03-11 15:57:40 +0100 | [diff] [blame] | 57 | unlet s:save_cpo |