Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request feature repeat command #51

Open
ghost opened this issue Aug 29, 2020 · 6 comments
Open

Request feature repeat command #51

ghost opened this issue Aug 29, 2020 · 6 comments

Comments

@ghost
Copy link

ghost commented Aug 29, 2020

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

Thank you :)

@dbalatero
Copy link
Owner

dbalatero commented Aug 29, 2020

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.

@ghost
Copy link
Author

ghost commented Aug 30, 2020

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.

@dbalatero
Copy link
Owner

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))

@ghost
Copy link
Author

ghost commented Aug 30, 2020

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

@dbalatero
Copy link
Owner

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

@ghost
Copy link
Author

ghost commented Sep 7, 2020

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

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

No branches or pull requests

1 participant