fix(ftplugin): source Lua files after Vimscript files per directory (#23801)

Problem: Lua ftplugins in runtime take precedence over Vimscript
ftplugins in user configs (even in `after/`).
Solution: Source ftplugins separately per directory, first Vimscript
then Lua.
This commit is contained in:
Christian Clason 2023-05-28 15:13:44 +02:00 committed by GitHub
parent 8e17054a23
commit 03a2c5b772
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,9 +28,11 @@ augroup filetypeplugin
" When there is a dot it is used to separate filetype names. Thus for " When there is a dot it is used to separate filetype names. Thus for
" "aaa.bbb" load "aaa" and then "bbb". " "aaa.bbb" load "aaa" and then "bbb".
for name in split(s, '\.') for name in split(s, '\.')
exe 'runtime! ftplugin/' . name . '.vim ftplugin/' . name . '_*.vim ftplugin/' . name . '/*.vim' " Load Lua ftplugins after Vim ftplugins _per directory_
" Load lua ftplugins " TODO(clason): use nvim__get_runtime when supports globs and modeline
exe printf('runtime! ftplugin/%s.lua ftplugin/%s_*.lua ftplugin/%s/*.lua', name, name, name) exe printf('runtime! ftplugin/%s.vim ftplugin/%s.lua', name, name)
exe printf('runtime! ftplugin/%s_*.vim ftplugin/%s_*.lua', name, name)
exe printf('runtime! ftplugin/%s/*.vim ftplugin/%s/*.lua', name, name)
endfor endfor
endif endif
endfunc endfunc