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

Implement dot-repeatability #7

Closed
1 task done
lbiaggi opened this issue Dec 30, 2022 · 8 comments
Closed
1 task done

Implement dot-repeatability #7

lbiaggi opened this issue Dec 30, 2022 · 8 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@lbiaggi
Copy link

lbiaggi commented Dec 30, 2022

Feature Requested

I think you could use something like my snippet, although it depends on vim-repeat. It's worth to use or at least suggest this way to bind.

vim.keymap.set("n", "]d", function() vim.diagnostic.goto_next { float = false } vim.call("repeat#set", "]d") end,
    { noremap = true })
vim.keymap.set("n", "[d", function() vim.diagnostic.goto_prev { float = false } vim.call("repeat#set", "[d") end,
    { noremap = true })
vim.keymap.set("n", "]D",
    function() vim.diagnostic.goto_next { severity = vim.diagnostic.severity.ERROR, float = false }
        vim.call("repeat#set"
            , "]D")
    end, { noremap = true })
vim.keymap.set("n", "[D",
    function() vim.diagnostic.goto_prev { severity = vim.diagnostic.severity.ERROR, float = false }
        vim.call("repeat#set"
            , "[D")
    end, { noremap = true })

Relevant Screenshot

No response

Checklist

  • The feature would be useful to more users than just me.
@lbiaggi lbiaggi added the enhancement New feature or request label Dec 30, 2022
@chrisgrieser
Copy link
Owner

thanks! I refrain from adding vim-repeat as dependency though, since I prefer to implement dot repeatability down the line without it. But I'll happily link to this info until then

@milanglacier
Copy link

https://www.vikasraj.dev/blog/vim-dot-repeat

This is a reference: you don't need vim-repeat to make it repeatable

@chrisgrieser
Copy link
Owner

Thanks! I'll look into it

@chrisgrieser chrisgrieser reopened this Jan 8, 2023
@chrisgrieser chrisgrieser added the help wanted Extra attention is needed label Jan 8, 2023
@chrisgrieser chrisgrieser changed the title Feature Request: expand repeat use Implement dot-repeatability Jan 8, 2023
@chrisgrieser
Copy link
Owner

Okay, so I looked into the linked guide as well as another guide I found and I am able to get simple examples with dot-repeatability going.

However, both guides as well as the example from op implement dot-repeatability for normal-mode, whereas for this plugin, I'd need to add dot repeatability to an mapping for operating-pending-mode, for which dot repeatability apparently has to be implemented differently (the objects needs to be fully called again, not the operator, which is already dot-repeatable).

Does someone here know any guides or plugins that explain how to make text objects dot-repeatable?

@chrisgrieser chrisgrieser pinned this issue Jan 8, 2023
@lbiaggi
Copy link
Author

lbiaggi commented Jan 11, 2023

@andrewferrier
Copy link

andrewferrier commented Mar 13, 2023

Okay, so I looked into the linked guide as well as another guide I found and I am able to get simple examples with dot-repeatability going.

However, both guides as well as the example from op implement dot-repeatability for normal-mode, whereas for this plugin, I'd need to add dot repeatability to an mapping for operating-pending-mode, for which dot repeatability apparently has to be implemented differently (the objects needs to be fully called again, not the operator, which is already dot-repeatable).

Does someone here know any guides or plugins that explain how to make text objects dot-repeatable?

@chrisgrieser it's not a guide per se, but you might find the implementation of dot-repeat in my debugprint.nvim plugin helpful, as it supports this for operator-pending mode: https://github.com/andrewferrier/debugprint.nvim/blob/ee5a3a83c87e6a50dcb1223212404240ca519bdd/lua/debugprint/init.lua#L346.

The challenge I think is that you have to decide whether dot-repeating repeats with the same value of the text object, or the same text object. For example, in my case, dot-repeating prints another debug line, with the value of the original text object from the first line printed (this is hard to explain, but try it). But you could presumably implement this such that it selects the text object again given the new cursor position.

I don't know if there's a standard approach there.

@chrisgrieser
Copy link
Owner

chrisgrieser commented Mar 31, 2023

Thanks to the a great find by @vypxl and @ii14, the plugin now supports dot-repeatability. 🥳

While this is a non-breaking change, you do need to change your keymaps to get dot-repeatability. See the README. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants