blob: 095e733715c8bd79f7fe419dde8442cdd63f8914 [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
Aliaksei Budavei40524742024-04-14 19:57:00 +03003" 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 Kearns93197fd2024-01-14 20:59:02 +01007" 2024 Jan 14 by Vim Project (browsefilter)
Bram Moolenaar071d4272004-06-13 20:20:40 +00008
9if exists("b:did_ftplugin") | finish | endif
10let b:did_ftplugin = 1
11
12" Make sure the continuation lines below do not cause problems in
13" compatibility mode.
14let s:save_cpo = &cpo
15set cpo-=C
16
Bram Moolenaar071d4272004-06-13 20:20:40 +000017" For filename completion, prefer the .java extension over the .class
18" extension.
19set 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.
23setlocal includeexpr=substitute(v:fname,'\\.','/','g')
24setlocal suffixesadd=.java
25if exists("g:ftplugin_java_source_path")
26 let &l:path=g:ftplugin_java_source_path . ',' . &l:path
27endif
28
29" Set 'formatoptions' to break comment lines but not other lines,
30" and insert the comment leader when hitting <CR> or using "o".
31setlocal formatoptions-=t formatoptions+=croql
32
33" Set 'comments' to format dashed lists in comments. Behaves just like C.
34setlocal comments& comments^=sO:*\ -,mO:*\ \ ,exO:*/
35
36setlocal commentstring=//%s
37
38" Change the :browse e filter to primarily show Java-related files.
Doug Kearns93197fd2024-01-14 20:59:02 +010039if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
Bram Moolenaar071d4272004-06-13 20:20:40 +000040 let b:browsefilter="Java Files (*.java)\t*.java\n" .
41 \ "Properties Files (*.prop*)\t*.prop*\n" .
Doug Kearns93197fd2024-01-14 20:59:02 +010042 \ "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 Moolenaar071d4272004-06-13 20:20:40 +000048endif
49
50" Undo the stuff we changed.
Bram Moolenaar8b879e72005-03-28 20:49:18 +000051let b:undo_ftplugin = "setlocal suffixes< suffixesadd<" .
Bram Moolenaar071d4272004-06-13 20:20:40 +000052 \ " formatoptions< comments< commentstring< path< includeexpr<" .
53 \ " | unlet! b:browsefilter"
54
55" Restore the saved compatibility options.
56let &cpo = s:save_cpo
Bram Moolenaar84f72352012-03-11 15:57:40 +010057unlet s:save_cpo