indent.vim 912 B

12345678910111213141516171819202122232425262728293031323334
  1. " Vim support file to switch on loading indent files for file types
  2. "
  3. " Maintainer: The Vim Project <https://github.com/vim/vim>
  4. " Last Change: 2023 Aug 10
  5. " Former Maintainer: Bram Moolenaar <Bram@vim.org>
  6. if exists("did_indent_on")
  7. finish
  8. endif
  9. let did_indent_on = 1
  10. augroup filetypeindent
  11. au FileType * call s:LoadIndent()
  12. func! s:LoadIndent()
  13. if exists("b:undo_indent")
  14. exe b:undo_indent
  15. unlet! b:undo_indent b:did_indent
  16. endif
  17. let s = expand("<amatch>")
  18. if s != ""
  19. if exists("b:did_indent")
  20. unlet b:did_indent
  21. endif
  22. " When there is a dot it is used to separate filetype names. Thus for
  23. " "aaa.bbb" load "indent/aaa.vim" and then "indent/bbb.vim".
  24. for name in split(s, '\.')
  25. " XXX: "[.]" in the pattern makes it a wildcard on Windows
  26. exe $'runtime! indent/{name}[.]{{vim,lua}}'
  27. endfor
  28. endif
  29. endfunc
  30. augroup END