nvim-ipy icon indicating copy to clipboard operation
nvim-ipy copied to clipboard

Add IPy-RunRegister

Open JohnReid opened this issue 5 years ago • 4 comments

Hi,

This is another PR to add a function that runs some python code. This time it is IPy-RunRegister that runs the contents of the default register. I find that visually selecting lines and using IPy-Run is not the most efficient as it moves the cursor. With IPy-RunRegister I can quickly yank parts of my code using text objects or motion commands without moving the cursor and run them efficiently.

A word of warning. I am no expert in vimscript but I think I did the mapping and all the rest of it the right way. I also fixed a few typos and add a note in the README.

Thanks again for a great plugin :)

JohnReid avatar Mar 20 '20 21:03 JohnReid

Hmm we probably want to do this using 'operatorfunc' for this. I have some old code for this, maybe if I will look into it in the weekend (if I don't get distracted :P).

bfredl avatar Mar 20 '20 21:03 bfredl

I added <Plug>(IPy-RunOp) (finally), will it cover your usecase?

bfredl avatar Mar 21 '20 09:03 bfredl

I can't seem to get it to work with text objects but it is working fine for motions.

E.g. if I go to the top of two paragraphs execute IPy-RunOp followed by '2}' IPython executes the 2 paragraphs

But if I am inside the two identically indented paragraphs and I do IPy-RunOp then 'ii' (an indent text-object) it does not execute the two paragraphs. However 'yii' does yank them.

The motions are enough for me but I wonder what is wrong with the text-objects.

JohnReid avatar Mar 21 '20 15:03 JohnReid

Hmm it seems we need to handle line-wise text objects manually

bfredl avatar Mar 22 '20 19:03 bfredl