ftplugin.vim (1270B)
1 " Vim support file to switch on loading plugins 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 7 if exists("did_load_ftplugin") 8 finish 9 endif 10 let did_load_ftplugin = 1 11 12 augroup filetypeplugin 13 au FileType * call s:LoadFTPlugin() 14 15 func! s:LoadFTPlugin() 16 if exists("b:undo_ftplugin") 17 exe b:undo_ftplugin 18 unlet! b:undo_ftplugin b:did_ftplugin 19 endif 20 21 let s = expand("<amatch>") 22 if s != "" 23 if &cpo =~# "S" && exists("b:did_ftplugin") 24 " In compatible mode options are reset to the global values, need to 25 " set the local values also when a plugin was already used. 26 unlet b:did_ftplugin 27 endif 28 29 " When there is a dot it is used to separate filetype names. Thus for 30 " "aaa.bbb" load "aaa" and then "bbb". 31 for name in split(s, '\.') 32 " Load Lua ftplugins after Vim ftplugins _per directory_ 33 " TODO(clason): use nvim__get_runtime when supports globs and modeline 34 " XXX: "[.]" in the first pattern makes it a wildcard on Windows 35 exe $'runtime! ftplugin/{name}[.]{{vim,lua}} ftplugin/{name}_*.{{vim,lua}} ftplugin/{name}/*.{{vim,lua}}' 36 endfor 37 endif 38 endfunc 39 augroup END