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

Send text in Visual mode #20

Closed
jduc opened this issue Jan 23, 2017 · 12 comments
Closed

Send text in Visual mode #20

jduc opened this issue Jan 23, 2017 · 12 comments

Comments

@jduc
Copy link
Contributor

jduc commented Jan 23, 2017

Hey,

Quick suggestion/question: often, it's convenient to select some text in visual mode and send it to the REPL rather than typing a motion.

There is surely an easy mapping/implementation to do that but my knowledge in vim plugins is close to 0 (shame on me) and if it's fast for you, I would really appreciate a little help.

What I did that kinda work for my ipython repl is:
vmap s <ESC>`>a<space><ESC>ctr`<
but as you can see, this adds a space at the end of the selection before sending otherwise it was sending the selected text minus the last character for some reason.

As this "solution" is pretty clunky, would you have another suggestion or would it be possible to implement another mapping like the ctr but for visual mode ?

Thanks a lot

@hkupty
Copy link
Collaborator

hkupty commented Jan 24, 2017

Hi!
That should be fairly easy to implement.. I'll take a look at that later on today.

Cheers,

@hkupty
Copy link
Collaborator

hkupty commented Jan 24, 2017

This commit (bb62179) actually implements ctr on visual mode, so this should be closed by now.

Feel free to reopen the issue if something is not working.

Cheers!

@hkupty hkupty closed this as completed Jan 24, 2017
@jduc
Copy link
Contributor Author

jduc commented Jan 25, 2017

Thanks a lot. I gave it a try but I encountered a small bug with multilines ipython and ptipython repl: when sending lines through visual, it is sending them multiple times depending on the number of lines sent . Here is an example code:

print("Hello")
print("World")

Sending these two lines via ctr} for instance prints

Hello
World

on two lines as expected. Now sending via v}ctr prints:

Hello
World
Hello
World

Now adding print("!") as a third line in the code and sending via visual mode prints out:

Hello
World
!
Hello
World
!
Hello
World
!

Are you getting the same behavior ? Thanks again for being so responsive, really appreciate it.

@hkupty hkupty reopened this Jan 25, 2017
@hkupty
Copy link
Collaborator

hkupty commented Jan 25, 2017

Ugh.. I tested this commit from another branch I'm working, testing and it did work fine. It seems that, since I've changed a bit how the logic works, backporting was not enough... I'll try to fix that.

Cheers

@hkupty
Copy link
Collaborator

hkupty commented Jan 25, 2017

I've merged the testing branch, which enhanced REPL management in several ways. It seems to solve this problem as well..

If the problem persists, don't refrain from reopening this issue!

Cheers!

@hkupty hkupty closed this as completed Jan 25, 2017
@jduc
Copy link
Contributor Author

jduc commented Jan 26, 2017

Thanks ! Unfortunately, it seems I'm unable update to the newer merge. Seems to be related to the zen submodule. Here is the error I get after the UpdateRemotePlugins command:

Encountered ModuleNotFoundError loading plugin at /home/user/.nvim/plugged/iron.nvim/rplugin/python3/iron: No module named 'zen'
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.6/site-packages/neovim/plugin/host.py", line 131, in _load
    module = imp.load_module(name, file, pathname, descr)
  File "/usr/lib/python3.6/imp.py", line 244, in load_module
    return load_package(name, filename)
  File "/usr/lib/python3.6/imp.py", line 216, in load_package
    return _load(spec)
  File "<frozen importlib._bootstrap>", line 675, in _load
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
ModuleNotFoundError: No module named 'zen'

@hkupty
Copy link
Collaborator

hkupty commented Jan 26, 2017

I'm sorry this has broken the update. It seems that it has not created the submodule.

Apparently, removing and installing again does the right thing (for me, using vim-plug). If it still does not create the submodule, pleas run a git submodule init and git submodule sync on your iron.nvim. It should suffice.

If it still does not create the submodule, we're in serious trouble.

Cheers

@hkupty hkupty reopened this Jan 26, 2017
@jduc
Copy link
Contributor Author

jduc commented Jan 26, 2017

:( outch, serious trouble it is... I'm also using vim-plug, I tried removing the iron.vim directory in the plugged folder and then :PlugInstall - still the same error. I also tried syncing the submodule as you suggested, still same error.

In the iron.vim directory, it seems the zen pluggin is there, pointing to ../../../deps/zen.nvim/src which contains the ui.py . Am I missing something, like a python lib ? Or could this be related to python3.6 ? Any other ideas ? Thanks a lot.

@hkupty
Copy link
Collaborator

hkupty commented Jan 26, 2017

I just found the bug.
master should be fixed by now.

Please test to see if it works for you.

Cheers

@jduc
Copy link
Contributor Author

jduc commented Jan 27, 2017

Everything works like a charm, well done and thank you very much!

@hkupty
Copy link
Collaborator

hkupty commented Jan 27, 2017

No problem! I'm really glad it works now!

Please keep on opening issues in case you find anything!

@hkupty hkupty closed this as completed Jan 27, 2017
@10b14224cc
Copy link

10b14224cc commented Feb 9, 2024

For those coming from Google, the new way to send visual selection to the REPL is to use core.visual_send.

Here is an example mapping:

vim.keymap.set(
    "v",
    "<leader>il",
    ":lua require('iron.core').visual_send()<CR><Esc>"
)

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

No branches or pull requests

3 participants