VSCodeVim / Vim

:star: Vim for Visual Studio Code
http://aka.ms/vscodevim
MIT License
14.02k stars 1.32k forks source link

Request Plugin Addition: vim-abolish by tpope #2435

Open endowdly opened 6 years ago

endowdly commented 6 years ago

Subvert and the coercion operators are some of my most used features in vim. I can't believe no-one has suggested it yet!?

Abolish may be a difficult thing to emulate, since it adds iabbrev commands to the .vimrc. But, the subvert substitution and the coercion operations are 🔥

endowdly commented 6 years ago

I am not super familiar with vimL/vimscript, nor am I familiar with ts. But, I do know C#/F# and js! I am also on a temporary assignment with lots of downtime, so I'll see if I can kludge something together for the extension. I will get started with the contributing guide ;)

alexpattison commented 5 years ago

@endowdly Did you ever make any progress with this? I would gladly take a stab at it if someone could point me in the right direction. It would be super nice for creating redux actions with something like createStandardAction.

endowdly commented 5 years ago

@AlexPattison sadly I did not make major progress.

I did get the mechanics of the vimscript worked out, however I had a hard time figuring out the 'API' of the extension. I ran into a pretty heavy roadblock when I realized that the coerce command would have to operate really similarly to the surround command. The VSCodeVim guys had to do some pretty serious hacking to get that to work in an appreciable way. I was able to get the extension to recognize when we wanted to go into 'coerce' mode, so there's a small victory.

vegerot commented 4 years ago

Why don't we have all tpope's plugins in here by default. He's such a legend, and seems like a no-brainer, given all the utility and demand for his plugins

J-Fields commented 4 years ago

@vegerot Generally because there's only so much we can do in our free time. Pull requests are always welcome.

endowdly commented 4 years ago

@vegerot I think there are a couple more issues besides the lack of manpower:

Because the editor is essentially a web-page, the plugin has to do a couple things: maintain a mode state, action state, and record inputs. There's only so many combinations of states and inputs we can do at any given time, and some vim plugins just can't play together well without removing a standard movement or action. ¯\_(ツ)_/¯

That said, I do think abolish is possible to emulate (closely) in its entirety:

  1. Abolish can write and read from an additional json file that would mimic the vimrc and store the abolish list. The then VsVim could just do a constant text search for those words when in insert mode and change them when they are complete.
  2. Subvert is just an expanded regex find&replace. This is probably the low hanging fruit because it can be placed in the command palette and accessed by the ex command mode like the other commands.
  3. Coerce is tricky as I mentioned before. The easiest way would be to do something like Sneak/EasyMotion does now or utilize difference key modifiers. Coerce would also need a similar hack like how Surround is implemented. This would be the highest difficulty addition.

If I had more time!

sql-koala commented 4 years ago

About coerce: So, you see the problem as to get it to work in the keyspace "cr_"? We can use berknams new remapper to make this quite easy, like so:

@RegisterAction
export class ActionCoerceCamel extends ActionCoerceBase {
  keys = ['<coercecamel>']; // needs to be all lower case
  style: CoerceStyle = 'camel';
}

Plus, users would need one mapping per style (later, it would be nice to be able to auto create these): nnoremap crm <coercecamel>

sql-koala commented 4 years ago

...

endowdly commented 3 years ago

Re: Abolish

I found a very good extension that accomplishes abolish-style corrections. Interestingly enough, the author gets it done in the manner I had guessed would be the easiest to do (settings file). If there is a way (through command, like in abolish) to add this to VsVim, then there ya go.

https://github.com/genesy/auto-correct