Skip to content

feat: support toggle for spider motion#76

Closed
sumit-sahrawat wants to merge 3 commits intochrisgrieser:mainfrom
sumit-sahrawat:toggle
Closed

feat: support toggle for spider motion#76
sumit-sahrawat wants to merge 3 commits intochrisgrieser:mainfrom
sumit-sahrawat:toggle

Conversation

@sumit-sahrawat
Copy link

Problem statement

This PR adds helper functions to toggle spider motion.

Proposed solution

We add the following methods:

  • require("spider").toggle() to toggle off/on
  • require("spider").is_enabled() to get the current state

The state is stored as require("spider.config").globalOptions.enabled which is initially set to true. The initial state can be overridden by passing is to require("spider").setup({ enabled = ... )

AI usage disclosure

I'm not that well versed with lua + nvim. The initial version was generated by AI but I did multiple iterations manually afterwards.

I've also tested it extensively locally. Using this as a keybind with the forked version:

Snacks.toggle({
  name = "Spider Motion",
  get = function()
    return require("spider").is_enabled()
  end,
  set = function(state)
    if require("spider").is_enabled() ~= state then
      require("spider").toggle()
    end
  end,
}):map("<leader>uk")

Checklist

  • Variable names follow camelCase convention.
  • All AI-generated code has been reviewed by a human.
  • The README.md has been updated for any new or modified functionality
    (the .txt file is auto-generated and does not need to be modified).

@chrisgrieser
Copy link
Owner

That's not really a problem statement. Why would you want to toggle the softer motions?

They are either supposed to replace the original motions or as additional motions you can map to other keys.

I don't see why a user would want to only temporarily use spider motions in a way that justifies such a toggle.

@sumit-sahrawat
Copy link
Author

I felt that it could be a bit annoying when working with codebases that have large multi-word camel/pascal cased identifiers. I wanted to try this out but didn't want to have it always be on, so I went with a toggle similar to the other features in LazyVim.

@sumit-sahrawat
Copy link
Author

@chrisgrieser I can create a wrapper over require("spider").motion in my own configs and implement the toggle that way. Feel free to close this one if you'd prefer to not land this.

@chrisgrieser
Copy link
Owner

chrisgrieser commented Feb 13, 2026

Yeah, I feel like this is so specific that it makes more sense as something in a personal config.

As an implementation tip: you can simplify the toggling by using vim.keymap.del to disable and then using vim.keymap.set to re-enable. Should be less than 10 lines total and does not require to touch spider's code at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants