java.vim 1.6 KB

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