ftplugin.vim 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. " Vim support file to switch on loading plugins for file types
  2. "
  3. " Maintainer: Bram Moolenaar <Bram@vim.org>
  4. " Last change: 2006 Apr 30
  5. if exists("did_load_ftplugin")
  6. finish
  7. endif
  8. let did_load_ftplugin = 1
  9. augroup filetypeplugin
  10. au FileType * call s:LoadFTPlugin()
  11. func! s:LoadFTPlugin()
  12. if exists("b:undo_ftplugin")
  13. exe b:undo_ftplugin
  14. unlet! b:undo_ftplugin b:did_ftplugin
  15. endif
  16. let s = expand("<amatch>")
  17. if s != ""
  18. if &cpo =~# "S" && exists("b:did_ftplugin")
  19. " In compatible mode options are reset to the global values, need to
  20. " set the local values also when a plugin was already used.
  21. unlet b:did_ftplugin
  22. endif
  23. " When there is a dot it is used to separate filetype names. Thus for
  24. " "aaa.bbb" load "aaa" and then "bbb".
  25. for name in split(s, '\.')
  26. exe 'runtime! ftplugin/' . name . '.vim ftplugin/' . name . '_*.vim ftplugin/' . name . '/*.vim'
  27. " Load lua ftplugins
  28. exe printf('runtime! ftplugin/%s.lua ftplugin/%s_*.lua ftplugin/%s/*.lua', name, name, name)
  29. endfor
  30. endif
  31. endfunc
  32. augroup END