dbalatero/VimMode.spoon

Request feature repeat command

Opened this issue · 6 comments

Would it be possible to add the repeat command, for example when using f<char> I press ; in normal mode to repeat.

Thank you :)

This requires a bunch of research on how this mechanism works on Vim, so if you'd like to see it can I request you look into it (via :h help) and report back here?

How do you decide what is repeated and what isn't? Not clear on it.

I found it under Left-right motions https://neovim.io/doc/user/quickref.html

It's really useful for quickly jumping to the next character.

Edit: I was going to mention Neovim headless but I think that breaks autocomplete if used in an editor. This method you're using is far more flexible and works brilliantly in xcode.

You've done an amazing job with this, I wish I had found it sooner.

If you are interested in adding this, you can clone this repo, and point your ~/.hammerspoon/Spoons/VimMode.spoon directory at the cloned repo. Then develop using it. I recommend binding a key like hyper + h to reload your hammerspoon config.

Things to point out:

  1. We don't track the last motion in the command state:

local state = {
charsEntered = "",
motion = nil,
motionTimes = nil,
operator = nil,
operatorTimes = nil,
pendingInput = nil
}

  1. This is where the motion is fired:

onfire = function(self)
local result = vim:fireCommandState()
if result.mode == "visual" then
if result.hadOperator then
self:enterNormal()
else
self:enterVisual()
end
else
if result.transition == "normal" then self:enterNormal()
else vim:exitAsync() end
end
end,

  1. All the normal mode keys are bound in here:

VimMode.spoon/lib/modal.lua

Lines 196 to 205 in a900bae

-- Normal mode
modal
:withContext('normal')
:bind({}, 'i', function() vim:exitAsync() end)
:bindMotionsToModal('operator')
:bindCountsToModal('operator')
:bind({}, 'c', operator(Change))
:bind({}, 'd', operator(Delete))
:bind({}, 'y', operator(Yank))
:bind({}, 'r', operatorNeedingChar(Replace, Right))

Thank you for pointing me in the right direction. I will give it a shot.

@assertcarlos If you don't end up working on this, please comment back here so I know this is an open request.

Hi @dbalatero I tried working on this but unfortunately ended up giving up after about a day of trying to get it to work.