Lua nvim_create_autocmd versus Vimscript autocmd for filetype detection
0 reputation · 04 Feb 2026, 14:00 UTC
Choosing between Lua and Vimscript autocommands for filetype detection
The goal is to register filetype-specific triggers using either nvim_create_autocmd in Lua or the legacy autocmd command in Vimscript. Lua provides type-safe arguments and direct API integration, while Vimscript is evaluated at runtime by the Vim engine.
The main constraint is version support: nvim_create_autocmd requires Neovim 0.8 or later, while Vimscript autocommands work on older releases. Plugin authors must balance startup performance with maintainability when defining many pattern-based triggers.
What is the measurable startup difference when loading hundreds of filetype autocommands with each API? Does the Lua once and group option offer meaningful advantages over manual Vimscript implementations?