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

Support operator-pending maps #275

Open
andrewferrier opened this issue Mar 17, 2022 · 5 comments
Open

Support operator-pending maps #275

andrewferrier opened this issue Mar 17, 2022 · 5 comments
Labels

Comments

@andrewferrier
Copy link

refactoring.nvim is really nice, and seems to be getting really robust! Thanks for your hard work on it.

It would be wonderful if it could support operator-pending maps in addition to visual mode maps. I'm an old school vimmer who's a bit saddened by how many plugins are defaulting to visual mode these days :(

Might be happy to work on it with a pull req if you'd be interested...

@pranavrao145
Copy link
Collaborator

@andrewferrier thanks for opening an issue. If you want to start a pull request on that, we'd be happy to accept your contribution! If you have any questions about the plugin's existing codebase, a great place to ask for help is the #refactoring channel on Prime's Discord server.

@ThePrimeagen
Copy link
Owner

Even some examples of what you would like could help!

@andrewferrier
Copy link
Author

Sorry for the slow response. What I guess I was looking for here was a custom operator, e.g. something like the ability to type gyr<text object> and have refactoring.nvim operate on the text object (like other custom operators, such as https://github.com/tpope/vim-commentary or NeoVim-generation equivalents). Currently refactoring only supports visual mode (as far as I know) but for me (an old-school vim guy) it's nicer to be able to specify the operator, then the text object. To be fair, some of the power of this is lost in the case of refactoring, since refactorings typically cannot be simply repeated using . (one of the main advantages of operators over visual mode), but still, it would be nice :)

I need to learn/develop a good pattern for creating custom operators in NeoVim without using VimL. If you're happy to keep this issue open, when I get some time I'll looking at creating a pull req for this.

@k-times-c
Copy link

k-times-c commented Jul 20, 2022

Hi all! thank you for this plugin! @andrewferrier I actually asked about this exact feature within primeagen's discord channel a couple days ago, and was referenced here!

One cool project, and strong example of how to implement custom operatorfunc in NeoVim is this tpope/vim-surround 2.0 plugin, kylechui/nvim-surround. See line nvim-surround/init.vim for an example of how the operator func is set! they've also implemented the dot operator as well there.

I still need to peruse the refactoring.nvim to really crystallize the "how" and form an opinion on "where" this feature should exist. Any feedback or helpful links are appreciated.

PS: for those less familiar with implementing custom operators, the Vimscript the Hard Way does a good job of explaining it. He even has a case study that implements a operator func mapper with the grep operator (in vimL of course) found here

edit: @andrewferrier I just saw that you've left some comments within the nvim-surround repo, so apologies for the old news. That being said.. Hopefully me linking it here, spurs the conversation forward.

@kylechui
Copy link

kylechui commented Jul 29, 2022

Hey all, nvim-surround author here. I personally don't have any experience with refactoring.nvim, but if anybody wants clarification with how the text-object/dot-repeat code works for my plugin, feel free to tag me with any questions :)

Edit: @k-times-c Unless I'm misunderstanding, I'm pretty sure that this case wouldn't require the use of custom operators, but rather operator functions (see :h opfunc).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants