java.vim 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. " Vim filetype plugin file
  2. " Language: Java
  3. "
  4. " This runtime file is looking for a new maintainer.
  5. "
  6. " Former maintainer: Dan Sharp
  7. " Last Change: 2012 Mar 11
  8. if exists("b:did_ftplugin") | finish | endif
  9. let b:did_ftplugin = 1
  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. " For filename completion, prefer the .java extension over the .class
  15. " extension.
  16. set suffixes+=.class
  17. " Enable gf on import statements. Convert . in the package
  18. " name to / and append .java to the name, then search the path.
  19. setlocal includeexpr=substitute(v:fname,'\\.','/','g')
  20. setlocal suffixesadd=.java
  21. if exists("g:ftplugin_java_source_path")
  22. let &l:path=g:ftplugin_java_source_path . ',' . &l:path
  23. endif
  24. " Set 'formatoptions' to break comment lines but not other lines,
  25. " and insert the comment leader when hitting <CR> or using "o".
  26. setlocal formatoptions-=t formatoptions+=croql
  27. " Set 'comments' to format dashed lists in comments. Behaves just like C.
  28. setlocal comments& comments^=sO:*\ -,mO:*\ \ ,exO:*/
  29. setlocal commentstring=//%s
  30. " Change the :browse e filter to primarily show Java-related files.
  31. if has("gui_win32")
  32. let b:browsefilter="Java Files (*.java)\t*.java\n" .
  33. \ "Properties Files (*.prop*)\t*.prop*\n" .
  34. \ "Manifest Files (*.mf)\t*.mf\n" .
  35. \ "All Files (*.*)\t*.*\n"
  36. endif
  37. " Undo the stuff we changed.
  38. let b:undo_ftplugin = "setlocal suffixes< suffixesadd<" .
  39. \ " formatoptions< comments< commentstring< path< includeexpr<" .
  40. \ " | unlet! b:browsefilter"
  41. " Restore the saved compatibility options.
  42. let &cpo = s:save_cpo
  43. unlet s:save_cpo