-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
Enable dot-repeatability after operators #4
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few issues why the current version of the PR won't run.
I think you could simply skip the whole <Plug>
and all the associated issues by telling the user that that the keymaps need to be added as:
Keymap({ "n", "o", "x" }, "b", '<cmd>lua require("spider").motion("b")<CR>', { desc = "Spider-b" })
which I tested with my version of the plugin and works nicely!
So could you revert the changes in the lua file, and instead make the respective changes to the README?
lua/spider.lua
Outdated
"", | ||
"<Plug>(spider-motion-" .. key .. ")", | ||
"<cmd>lua require('spider').motion('" .. key .. "')<CR>" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code is not valid, it's missing an end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, was kinda in a hurry earlier :)
Didn't test it
lua/spider.lua
Outdated
@@ -147,6 +147,14 @@ function M.motion(key) | |||
if isOperatorPending and key == "e" then col = col + 1 end | |||
|
|||
vim.api.nvim_win_set_cursor(0, { row, col }) | |||
|
|||
-- set plug keymaps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even with the end
added, the plugin still won't run, since you set the <Plug>
keymaps inside the function they are supposed to call. You would need set them up elsewhere, e.g. in the setup function (which is then becoming mandatory for dot repeats)
README.md
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on line 70 (github won't let me comment it, since you haven't changed it), I think the lazy-loading needs to be dropped since, since iirc <Plug>
keymaps do not play nice with lazy loading.
That being said, awesome, thank you so much! I did tons of research and asked around a lot, but did not come up with a solution that works. May I ask where you got the info that it's the |
Well, I did research because I really wanted it to work, and I saw you everywhere this topic came up, so I did some testing. Then I kinda gave up and filed that issue with neovim itself, when @ii14 pointed out that ex commands could be used as repeatable motions for operators. I tried that, first using vim style |
To the issue with the plug mapping, yeah I recall having problems with that in my config. |
great, this works now! btw, I also updated the various textobjs plugin, in case you are using it. |
lazy.vim: return {
"chrisgrieser/nvim-spider",
keys = {
{ "ew", function() require("spider").motion("w") end, desc = "Spider-w", mode = { "n", "o", "x" } },
{ "ee", function() require("spider").motion("e") end, desc = "Spider-e", mode = { "n", "o", "x" } },
{ "eb", function() require("spider").motion("b") end, desc = "Spider-b", mode = { "n", "o", "x" } },
{ "ge", function() require("spider").motion("ge") end, desc = "Spider-ge", mode = { "n", "o", "x" } },
},
opts = {
skipInsignificantPunctuation = false,
},
} Am I doing something wrong or should I open an issue? |
@utkarshgupta137 yes in general, you should open an issue instead of commenting on an unrelated PR. In your particular case the issue arises because you are not using the You can use this snippet: return {
"chrisgrieser/nvim-spider",
init = function()
vim.keymap.set({"n", "o", "x"}, "ew", "<cmd>lua require('spider').motion('w')<CR>", { desc = "Spider-w" })
vim.keymap.set({"n", "o", "x"}, "ee", "<cmd>lua require('spider').motion('e')<CR>", { desc = "Spider-e" })
vim.keymap.set({"n", "o", "x"}, "eb", "<cmd>lua require('spider').motion('b')<CR>", { desc = "Spider-b" })
vim.keymap.set({"n", "o", "x"}, "ge", "<cmd>lua require('spider').motion('ge')<CR>", { desc = "Spider-ge" })
end,
opts = {
skipInsignificantPunctuation = false,
},
} |
I looked into how to dot-repeat motions and textobjects. It cost me many hours of my life.
But, thanks to @ii14 I found a solution.
It seems that dot repeating an operator-motion combination requires the motion to be a built in motion, or an ex command, which somehow moves the cursor.
This means, it is possible to dot-repeat a spider-y
dw
for example, by mappingw
not tofunction() require...
but to<cmd>lua require...
. That way, that command is used as the motion to be repeated when bound in operator-pending mode.I put together a little patch that applies this. I hope this helps, and maybe it helps for the problems in nvim-various-textobjs (chrisgrieser/nvim-various-textobjs#7) as well :)