spamguard.nvim ๐Ÿ›ก๏ธ

May 5, 2025 ยท View on GitHub

Awesome

A minimal Neovim plugin that detects excessive key spamming (jjjjjj) and suggests more efficient alternatives.

๐Ÿ“ฟ๏ธ Demo (neovide)

Demo of spamguard.nvim

โœจ Features

  • Detects spam on keys like j, k, h, l, w
  • Displays suggestions for more effective motion usage (e.g. use 10j)
  • Tracks daily and weekly key usage
  • Command :SpamStats to view usage stats
  • Fully configurable thresholds and suggestions ๐ŸŒŸ
  • Ignores common explorer/file manager filetypes (neo-tree, NvimTree, etc.)
  • Can be disabled per-buffer with vim.b.disable_spamguard = true

๐Ÿš€ Installation

Using lazy.nvim:

return {
  "timseriakov/spamguard.nvim",
  event = "VeryLazy",
  config = function()
    local spamguard = require("spamguard")
    spamguard.setup({
      keys = {
        j = { threshold = 9, suggestion = "use s / f instead of spamming jjjj ๐Ÿ˜Ž" },
        k = { threshold = 9, suggestion = "try { of ( instead of spamming kkkk ๐Ÿ˜Ž" },
        h = { threshold = 9, suggestion = "use b / 0 / ^ instead of spamming hhhh  ๐Ÿ˜Ž" },
        l = { threshold = 9, suggestion = "try w / e / f โ€” it's faster! ๐Ÿ˜Ž" },
        w = { threshold = 8, suggestion = "use s / f โ€” more precise and quicker! ๐Ÿ˜Ž" },
      },
    })
    vim.schedule(function()
      spamguard.enable()
    end)
  end,
}

If a key is not listed in your config, it will fall back to the default behavior.


๐Ÿ“Š Commands

  • :SpamStats โ€” Show usage stats:
    • ๐Ÿ“… For today
    • ๐Ÿ“๏ธ For the last 7 days

๐Ÿง  Disabling for specific buffers

You can disable spamguard in a specific buffer like this:

vim.b.disable_spamguard = true

This is useful for excluding special-purpose buffers or floating windows where tracking is not desired.


๐Ÿ“„ License

MIT ยฉ Tim Seriakov