xref: /vim-8.2.3635/runtime/indent.vim (revision 1015fde3)
1071d4279SBram Moolenaar" Vim support file to switch on loading indent files for file types
2071d4279SBram Moolenaar"
3071d4279SBram Moolenaar" Maintainer:	Bram Moolenaar <[email protected]>
4*1015fde3SBram Moolenaar" Last Change:	2008 Feb 22
5071d4279SBram Moolenaar
6071d4279SBram Moolenaarif exists("did_indent_on")
7071d4279SBram Moolenaar  finish
8071d4279SBram Moolenaarendif
9071d4279SBram Moolenaarlet did_indent_on = 1
10071d4279SBram Moolenaar
11071d4279SBram Moolenaaraugroup filetypeindent
12582fd85bSBram Moolenaar  au FileType * call s:LoadIndent()
13582fd85bSBram Moolenaar  func! s:LoadIndent()
14582fd85bSBram Moolenaar    if exists("b:undo_indent")
15582fd85bSBram Moolenaar      exe b:undo_indent
16582fd85bSBram Moolenaar      unlet! b:undo_indent b:did_indent
17582fd85bSBram Moolenaar    endif
18*1015fde3SBram Moolenaar    let s = expand("<amatch>")
19*1015fde3SBram Moolenaar    if s != ""
20582fd85bSBram Moolenaar      if exists("b:did_indent")
21582fd85bSBram Moolenaar	unlet b:did_indent
22582fd85bSBram Moolenaar      endif
23*1015fde3SBram Moolenaar
24*1015fde3SBram Moolenaar      " When there is a dot it is used to separate filetype names.  Thus for
25*1015fde3SBram Moolenaar      " "aaa.bbb" load "indent/aaa.vim" and then "indent/bbb.vim".
26*1015fde3SBram Moolenaar      for name in split(s, '\.')
27*1015fde3SBram Moolenaar	exe 'runtime! indent/' . name . '.vim'
28*1015fde3SBram Moolenaar      endfor
29582fd85bSBram Moolenaar    endif
30582fd85bSBram Moolenaar  endfunc
31071d4279SBram Moolenaaraugroup END
32