Repository navigation
[audit] Fix vim-sneak module guard — use autoload check instead of require - #113
Conversation
…dule)
pcall(require, "sneak") always returns false because vim-sneak is a
Vimscript plugin with no Lua module named "sneak". This silently
disabled all sneak configuration: label mode, smartcase, and the
f/F/t/T keymaps were never applied.
Replace the require guard with vim.fn.exists("*sneak#wrap"), which
checks for the plugin's actual autoload entry point.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e8b19b97cb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| local sneaks_ok, _ = pcall(require, "sneak") | ||
| -- vim-sneak is a Vimscript plugin: it has no Lua module, so require("sneak") always fails. | ||
| -- Check for its autoload entry point instead. | ||
| local sneaks_ok = vim.fn.exists("*sneak#wrap") == 1 |
There was a problem hiding this comment.
Use a plugin-load marker instead of an autoload function
When vim-sneak is installed, this guard still evaluates false because sneak#wrap lives in autoload/sneak.vim; Vim/Neovim autoload functions are not defined until the function is first called or the autoload file is explicitly sourced. The plugin’s startup script only installs mappings whose RHS calls sneak#wrap, so at plugin_config.lua startup this check leaves the entire configuration block dead and the intended f/F/t/T mappings are still skipped. Check a startup marker such as g:loaded_sneak_plugin (or the installed <Plug> mapping) instead.
Useful? React with 👍 / 👎.
|
there is lua/sneak.lua that is loadable, and current check returns true |
|
so sneak.lua appears to handle highlight, i suppose that is sufficient for simple check but you can update pr if better approach exists. this is what sneak.lua does: |
|
Claude finished @stanfish06's task in 1m 47s —— View job Updated guard to
|
sneak#wrap lives in autoload/sneak.vim and is not defined at startup,
making vim.fn.exists("*sneak#wrap") always return 0. The standard Vim
idiom is to check the g:loaded_* variable that plugin/sneak.vim sets
when it sources.
Co-authored-by: Zhiyuan <stanfish06@users.noreply.github.com>
What
lua/config/plugin_config.lua(line 43, before this PR) guarded all vim-sneak configuration behind:vim-sneakis a Vimscript plugin — it has no Lua module namedsneak.pcall(require, "sneak")therefore always returnsfalse, silently making the entire block dead code:vim.g["sneak#label"] = 1(label/EasyMotion-style jump targets) — never setvim.g["sneak#use_ic_scs"] = 1(smartcase) — never setf,F,t,Tremapped to<Plug>Sneak_f/F/t/T— never appliedThe plugin itself loads fine (it lives in
pack/plugins/start/sneaks.vim/), but all its configuration was silently dropped every time Neovim started.Where
lua/config/plugin_config.lua, previously line 43.Why it matters
Without label mode the plugin is functionally equivalent to plain
f/t— the distinguishing EasyMotion-style jump-target overlay never appears. The smartcase option also stays off.Fix
Replace the Lua-module
requireguard with a check against vim-sneak's actual autoload entry point:sneak#wrapis the function vim-sneak's Vimscript defines on load. It is present if and only if the plugin was sourced, making it the correct runtime probe for a Vimscript plugin.Testing
sneaks.vimas usual (SyncPkgs).f— jump-target labels should appear (EasyMotion-style).sneak#use_ic_scs, typing an uppercase char should match only that case.sneaks_okisfalseand nothing is set (same behavior as before).Generated by Claude Code