diff options
author | Gregory Anders <8965202+gpanders@users.noreply.github.com> | 2022-01-17 14:11:59 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-17 14:11:59 -0700 |
commit | fcf5dd34fdfde3a6632b96a88f66c1053cba08d1 (patch) | |
tree | 941f2e41b681d26429fe1ae9c6276a4c7519512b /src | |
parent | ad2dbd4b5f2cfa740e373fff0e021e2163909cfb (diff) | |
download | rneovim-fcf5dd34fdfde3a6632b96a88f66c1053cba08d1.tar.gz rneovim-fcf5dd34fdfde3a6632b96a88f66c1053cba08d1.tar.bz2 rneovim-fcf5dd34fdfde3a6632b96a88f66c1053cba08d1.zip |
refactor: enable filetype detection before user startup scripts (#17040)
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/main.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/nvim/main.c b/src/nvim/main.c index cbd1f53727..9d1c2ad834 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -341,9 +341,11 @@ int main(int argc, char **argv) init_default_autocmds(); TIME_MSG("init default autocommands"); + bool vimrc_none = params.use_vimrc != NULL && strequal(params.use_vimrc, "NONE"); + // Reset 'loadplugins' for "-u NONE" before "--cmd" arguments. // Allows for setting 'loadplugins' there. - if (params.use_vimrc != NULL && strequal(params.use_vimrc, "NONE")) { + if (vimrc_none) { // When using --clean we still want to load plugins p_lpl = params.clean; } @@ -351,14 +353,20 @@ int main(int argc, char **argv) // Execute --cmd arguments. exe_pre_commands(¶ms); + if (!vimrc_none) { + // Does ":filetype plugin indent on". We do this *before* the user startup scripts to ensure + // ftplugins run before FileType autocommands defined in the init file (which allows those + // autocommands to overwrite settings from ftplugins). + filetype_maybe_enable(); + } + // Source startup scripts. source_startup_scripts(¶ms); // If using the runtime (-u is not NONE), enable syntax & filetype plugins. - if (params.use_vimrc == NULL || !strequal(params.use_vimrc, "NONE")) { - // Does ":filetype plugin indent on". - filetype_maybe_enable(); - // Sources syntax/syntax.vim, which calls `:filetype on`. + if (!vimrc_none) { + // Sources syntax/syntax.vim. We do this *after* the user startup scripts so that users can + // disable syntax highlighting with `:syntax off` if they wish. syn_maybe_enable(); } |