0
0
mirror of https://github.com/vim/vim.git synced 2025-07-04 23:07:33 -04:00
vim/runtime/ftplugin.vim

43 lines
1.0 KiB
VimL
Raw Normal View History

2022-02-09 21:50:44 +00:00
vim9script noclear
2004-06-13 20:20:40 +00:00
2022-02-09 21:50:44 +00:00
# Vim support file to switch on loading plugins for file types
#
# Maintainer: Bram Moolenaar <Bram@vim.org>
# Last change: 2022 Feb 09
if exists("g:did_load_ftplugin")
2004-06-13 20:20:40 +00:00
finish
endif
2022-02-09 21:50:44 +00:00
g:did_load_ftplugin = 1
2004-06-13 20:20:40 +00:00
augroup filetypeplugin
2022-02-09 21:50:44 +00:00
au FileType * call LoadFTPlugin()
augroup END
2006-04-30 18:54:39 +00:00
2022-02-09 21:50:44 +00:00
if exists('*LoadFTPlugin')
# No need to define the function again.
finish
endif
def LoadFTPlugin()
if exists("b:undo_ftplugin")
exe b:undo_ftplugin
unlet! b:undo_ftplugin b:did_ftplugin
endif
2006-03-18 21:40:56 +00:00
var s = expand("<amatch>")
if s != ""
if &cpo =~# "S" && exists("b:did_ftplugin")
# In compatible mode options are reset to the global values, need to
# set the local values also when a plugin was already used.
unlet b:did_ftplugin
2004-06-13 20:20:40 +00:00
endif
# When there is a dot it is used to separate filetype names. Thus for
# "aaa.bbb" load "aaa" and then "bbb".
for name in split(s, '\.')
exe 'runtime! ftplugin/' .. name .. '.vim ftplugin/' .. name .. '_*.vim ftplugin/' .. name .. '/*.vim'
endfor
endif
enddef