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

change mapping into function-based interface #56

Merged
merged 8 commits into from Mar 28, 2023
Merged

Conversation

monaqa
Copy link
Owner

@monaqa monaqa commented Jan 25, 2023

This PR changes require("dial.map").inc_normal and others into function, which enables us to set group_name dynamically.

  • support dot repeating
  • support [count]
  • update document

To support count, maybe we have to break the existing interface.

@leiserfg
Copy link
Contributor

Maybe you can use vim.v.count1 to get the count in the function and pass it somehow?

@leiserfg
Copy link
Contributor

The count works fine for . like 3<c-a> does not add only once but then 2. works fine, I will try to find why so we can merge this after.

@leiserfg
Copy link
Contributor

leiserfg commented Feb 8, 2023

Hi @monaq any way I can help to get this merged?

@monaqa
Copy link
Owner Author

monaqa commented Feb 8, 2023

Thanks. I am currently considering what procedure would be preferable for the merge.
It is a kind of breaking change, and I want to reduce the impact on users as much as possible.

@monaqa monaqa marked this pull request as ready for review March 26, 2023 13:16
@monaqa monaqa changed the title [WIP] change mapping into function-based interface change mapping into function-based interface Mar 26, 2023
@monaqa
Copy link
Owner Author

monaqa commented Mar 26, 2023

To avoid breaking changes, instead of modifying the inc_normal function and others, a new function manipulate was added to support the functional interface.

function M.manipulate(direction, mode, group_name, count)
if count == nil then
count = vim.v.count1
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was the removal of apply_if_function intentional?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I have decided it is not necessary because the evaluation of group_name can be delayed by the following:

vim.keymap.set("n", "<C-a>", function()
    local group_name = evaluate_some_expr()
    require("dial.map").manipulate("increment", "normal", group_name)
end)

@monaqa monaqa merged commit 0fb00f5 into master Mar 28, 2023
4 checks passed
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.

None yet

2 participants