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

Use the appropriate replacement function for aliases #139

Closed
haoming-li-ling opened this issue Aug 14, 2022 · 4 comments
Closed

Use the appropriate replacement function for aliases #139

haoming-li-ling opened this issue Aug 14, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@haoming-li-ling
Copy link

I have an alias for two surrounds, both of which have replacement functions defined in the change table. When I invoke a change of surrounds (cs<alias>) with the alias, however, neither replacement function is applied, and the behavior falls back to waiting for a single surround character. I think the desired behavior should be to apply the replacement that belongs to the actual surrounds triggered by the alias in the context.

@haoming-li-ling haoming-li-ling added the enhancement New feature or request label Aug 14, 2022
@kylechui
Copy link
Owner

Can you provide an example of what is exactly the problem? Like your setup function + buffer + keymap combo?

@kylechui
Copy link
Owner

kylechui commented Aug 14, 2022

Sample config:

require("nvim-surround").setup({
    surrounds = {
        [")"] = {
            change = {
                replacement = { "(", ")" },
            },
        },
        ["}"] = {
            change = {
                replacement = { "{", "}" },
            },
        },
    },
    aliases = {
        ["o"] = { ")", "}" },
    },
})

Buffer:

{(test)}

The keymap cso shouldn't wait for another keypress, but should directly trigger the replacement key.

@kylechui kylechui added this to the Release v2.1.0 milestone Aug 14, 2022
@kylechui kylechui self-assigned this Aug 14, 2022
@kylechui
Copy link
Owner

Note to self: When computing nearest selection, return which character from the alias table was actually used to find the selections.

@kylechui
Copy link
Owner

kylechui commented Feb 9, 2023

Closing this as it seems to incur high cost for little utility, and is related to #98.

@kylechui kylechui closed this as completed Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants