kylechui / nvim-surround

Add/change/delete surrounding delimiter pairs with ease. Written with :heart: in Lua.
MIT License
2.92k stars 60 forks source link

Implement change_line mapping #245

Closed srithon closed 1 year ago

srithon commented 1 year ago

This PR addresses #244.

As of this commit, given the input, where | denotes the cursor position:

let x = foo(args|);

cS)( yields:

let x = foo(|
    args
);

The indentation of args depends on the indentation rules for the filetype.

We still need to iron out behavior for complex surrounds like HTML tags and functions. Currently, given the input, where | denotes the cursor position:

let x = foo(args|);

Both csf AND cSf with bar would yield:

let x = |bar(args);

This follows because the change target selection is just the foo. However, users may instead want the result to be:

let x = |bar(
    args
);

This is more useful because otherwise, cs and cS would be exhibiting the same behavior.

kylechui commented 1 year ago

Hi there, thanks so much for the PR! I'll be leaving a few comments here and there but so far the majority of it looks good to me :)

kylechui commented 1 year ago

Wow, thanks for the great PR! I can't see any more issues with it; once you fix the one comment I made I'd be glad to merge this in

srithon commented 1 year ago

Wow, thanks for the great PR! I can't see any more issues with it; once you fix the one comment I made I'd be glad to merge this in

No problem, glad to help. On a side note, this is a super nice codebase! The code was overall really easy to understand, and things were organized in a clean and logical way. Even before reading your contribution guide, and having minimal knowledge of writing Lua code, I was still able to understand what everything was doing and what I should change to implement the feature.

Thanks for writing this plugin! :)

kylechui commented 1 year ago

Thanks for the kind words! If you do spot anything you think could be improved, please let me know. Thanks again for the PR