From 7f7a200b85f73c4bfc9a03c50d524ee1f7a88436 Mon Sep 17 00:00:00 2001 From: m1ngsama Date: Sun, 17 May 2026 14:08:20 +0800 Subject: [PATCH] Fix built-in plugin guards for old-style runtime plugins (#82) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit env.vim sets g:loaded_X for twelve built-in plugins to short-circuit them. A prior fix corrected the casing on g:loaded_logiPat, but four of those plugins actually check the unscoped loaded_X form, not g:loaded_X — so those four guards have been doing nothing. Affected (all old runtime plugins predating the g:loaded_ convention): - gzip.vim checks `loaded_gzip` - logiPat.vim checks `loaded_logiPat` - rrhelper.vim checks `loaded_rrhelper` - spellfile.vim checks `loaded_spellfile_plugin` Set both forms (g: and unscoped) for those four — belt and suspenders. Empirically saves ~270μs at startup, mostly from gzip which was loading its full autocmd group on every launch. Add a regression assertion: source .vimrc, verify the four unscoped guards exist. Closes #81 --- CHANGELOG.md | 5 +++++ modules/env.vim | 12 +++++++----- scripts/test.sh | 4 ++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b5e8b3..3784352 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,11 @@ ### Fixed +- Built-in plugin guards for `gzip`, `logiPat`, `rrhelper`, and + `spellfile_plugin` are now set in both `g:`-prefixed and unscoped + forms — those four old-style runtime plugins check `loaded_X` (no + `g:`), so the previous `g:loaded_X` lines did nothing. Saves ~270μs + total at startup, mostly from gzip - `install.sh` interactive menu and QUICKSTART now show `,ff` (current fuzzy-find binding) instead of the stale `Ctrl+p` left over from the native-first cleanup; `.github/demo.tape` updated to match (the diff --git a/modules/env.vim b/modules/env.vim index 94ee91f..6e0a3b6 100644 --- a/modules/env.vim +++ b/modules/env.vim @@ -42,16 +42,18 @@ let g:chopsticks_markdown_conceal = get(g:, 'chopsticks_markdown_conceal', let g:chopsticks_lsp_virtual_text = get(g:, 'chopsticks_lsp_virtual_text', \ s:profile_full && !g:is_tty) -" Skip built-in plugins we never use +" Skip built-in plugins we never use. +" Modern plugins check g:loaded_X; older ones (gzip, logiPat, rrhelper, +" spellfile) check the unscoped loaded_X form, so we set both. let g:loaded_2html_plugin = 1 let g:loaded_getscriptPlugin = 1 -let g:loaded_gzip = 1 -let g:loaded_logiPat = 1 -let g:loaded_rrhelper = 1 +let g:loaded_gzip = 1 | let loaded_gzip = 1 +let g:loaded_logiPat = 1 | let loaded_logiPat = 1 +let g:loaded_rrhelper = 1 | let loaded_rrhelper = 1 let g:loaded_tarPlugin = 1 let g:loaded_vimballPlugin = 1 let g:loaded_zipPlugin = 1 let g:loaded_tutor_mode_plugin = 1 -let g:loaded_spellfile_plugin = 1 +let g:loaded_spellfile_plugin = 1 | let loaded_spellfile_plugin = 1 let g:loaded_openPlugin = 1 let g:loaded_manpager_plugin = 1 diff --git a/scripts/test.sh b/scripts/test.sh index e3759e8..41d9a7c 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -265,6 +265,10 @@ check_vim() { -c 'if !g:is_tty || &ttimeoutlen != 50 | cquit | endif' \ -c 'qa!' 2>&1 + XDG_CONFIG_HOME="$EMPTY_XDG" vim -u .vimrc -i NONE -es -N \ + -c 'if !exists("loaded_gzip") || !exists("loaded_logiPat") || !exists("loaded_rrhelper") || !exists("loaded_spellfile_plugin") | cquit | endif' \ + -c 'qa!' 2>&1 + XDG_CONFIG_HOME="$EMPTY_XDG" vim -u .vimrc -i NONE -es -N \ -c 'silent! delcommand LspStatus' \ -c 'silent! delcommand LspInstallServer' \