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

code is sent to the ipython console but not run #351

Open
Alan-Manning opened this issue Sep 27, 2023 · 16 comments
Open

code is sent to the ipython console but not run #351

Alan-Manning opened this issue Sep 27, 2023 · 16 comments
Labels

Comments

@Alan-Manning
Copy link

Alan-Manning commented Sep 27, 2023

Hello,

I have got this working as i want it in terms of splits and everything but i cant get the code i send to the IPython colsole i have to run. I send it and then it just sits there and i have to switch to the split and then go into instert mode to press enter and then tab back out to the python file i was in before. Im pretty sure this is not intended. Anybody know why this might be happening?

I have posted a pic of the setup below.

0PBluaAY5v

Untitled.video.-.Made.with.Clipchamp.mp4

Any help appreciated.

Thank you

  • Alan Manning
@PyDataBlog
Copy link

+1 I have the same issue here

@Alan-Manning
Copy link
Author

+1 I have the same issue here

found that there is a plugin called toggle term and you can set up a keymap for ipython console. This also has commands to sent lines, visual selection etc to the terminal. here is a video showing it with the setup, he uses python but can easily be changed to ipython, https://youtu.be/5OD-7h7gzxU.
The docs for toggle term show the ipython console example there with sending line etc to it, https://github.com/akinsho/toggleterm.nvim#termselect.

Hope this helps.

@PyDataBlog
Copy link

+1 I have the same issue here

found that there is a plugin called toggle term and you can set up a keymap for ipython console. This also has commands to sent lines, visual selection etc to the terminal. here is a video showing it with the setup, he uses python but can easily be changed to ipython, https://youtu.be/5OD-7h7gzxU. The docs for toggle term show the ipython console example there with sending line etc to it, https://github.com/akinsho/toggleterm.nvim#termselect.

Hope this helps.

Thanks! I will check it out. It's a shame this issue is holding me back from using this plugin.

@g-plus-theworld
Copy link

Hiya,

I had this issue and I found a workaround that is suitable for me. Until the ipython issue is fixed, you can switch to use the python executable instead. Like instead of typing "ipython" to the terminal you will get a REPL that looks like as if you have entered "python" or "python3". Here is what I did:

I use lazy as my package manager on windows so my plugins are downloaded to this folder:
C:/Users/"myusername"/AppData/Local/nvim-data/lazy/

Here I opened this file:
C:/Users/"myusername"/AppData/Local/nvim-data/lazy/iron.nvim/lua/iron/fts/python.lua

And edited line 31 (for me that is), to point ipython to the python executable.
image

Now when I open IronRepl It opens a "python" terminal and I can send code to it and it will execute.

Hope this helps and you can keep using the great plugin! :)

@PyDataBlog
Copy link

Hiya,

I had this issue and I found a workaround that is suitable for me. Until the ipython issue is fixed, you can switch to use the python executable instead. Like instead of typing "ipython" to the terminal you will get a REPL that looks like as if you have entered "python" or "python3". Here is what I did:

I use lazy as my package manager on windows so my plugins are downloaded to this folder:

C:/Users/"myusername"/AppData/Local/nvim-data/lazy/

Here I opened this file:

C:/Users/"myusername"/AppData/Local/nvim-data/lazy/iron.nvim/lua/iron/fts/python.lua

And edited line 31 (for me that is), to point ipython to the python executable.

image

Now when I open IronRepl It opens a "python" terminal and I can send code to it and it will execute.

Hope this helps and you can keep using the great plugin! :)

I also switched to Toggle term. Exactly what I needed.

@hkupty hkupty added the bug label Mar 31, 2024
@nickeisenberg
Copy link
Contributor

@g-plus-theworld @PyDataBlog @Alan-Manning Are you guys still using the pluggin and if so are you having the same problem. I am unable to reproduce the error you guys are having.

@Alan-Manning
Copy link
Author

@g-plus-theworld @PyDataBlog @Alan-Manning Are you guys still using the pluggin and if so are you having the same problem. I am unable to reproduce the error you guys are having.

i am not using this anymore. just using toggle term and launching ipython console through that. I think that there may be some ipython settings for smart return/ make a new line and not run if command is incomplete, i cant recall what its called. i have had some issues with other setups ive tinkered with because of this and might not be specifically related to this plugin, However if you do find out what causes this, id imagine a section in the readme about that might be usefull to others

@nickeisenberg
Copy link
Contributor

@Alan-Manning Hey how were you sending code to the terminal. where you using visual_send?

@PyDataBlog
Copy link

@Alan-Manning Hey how were you sending code to the terminal. where you using visual_send?

Use toggleterm plugin

@nickeisenberg
Copy link
Contributor

@PyDataBlog mainly asking to see if the problem can be solved.

@PyDataBlog
Copy link

@PyDataBlog mainly asking to see if the problem can be solved.

I switched plugins so can't verify

@roteiro
Copy link

roteiro commented May 3, 2024

@nickeisenberg I still have the issues described in this thread. My environment:

  • Windows 10 (Powershell 5.1.19041.429),
  • IPython 8.24.0
  • Windows Terminal 1.19.10821.0.

The behaviour seems to be the same, regardless if I use iron or toggleterm. I didn't do detailed tests with iron yet, but with toggleterm, the code is not executed regardless whether I use visual send or send current line.
If I launch with ipython --simple-prompt, the code is executed correctly.
@PyDataBlog did you do any specific configuration for toggleterm to get direct execution or did it work out of the box?

I'd be happy to see this issue resolved and can provide further input if needed.

@nickeisenberg
Copy link
Contributor

nickeisenberg commented May 4, 2024

Hey @roteiro, I think I fixed the issue. If you have time, could you do me a favor and test it on your end? Can you use your package manager to install my fork of iron.nvim and see if the changes fix the ipython issue you were having. My fork is located at nickeisenberg/iron.nvim, this fork is exactly the same as the original, so all you need to do is replace Vigemus/iron.nvim with nickeisenberg/iron.nvim in your package manager and the rest of your setup can stay the same. I tested the changes on my end with windows11 and it seemed to be working. I think at the moment, windows will only work with ipython, at least that has been my experience when using powershell.

@roteiro
Copy link

roteiro commented May 6, 2024

@nickeisenberg great, it works! I tested send line, send file and visual send. As I understood from your commit, you deferring the final cr call. Could you elaborate on the root of the problem?

€: If I send a file with many lines, such that the sending process takes quite long, the issue is still there. Probably because the sending takes longer than the added deferall?

@nickeisenberg
Copy link
Contributor

nickeisenberg commented May 6, 2024

@roteiro How many lines are you trying to send? I am unsure what the real issue is because it doesnt occur on linux or mac. I can try and mess around with it some more.

E: I just tested it and I see what you mean, I do not have this issue with windows + powershell + python, its only with ipython. In the meantime, an quick fix is to add the cr keymap to your setup. then <space><cr> will run the code that never ran in the ipython terminal.

return {
  "Vigemus/iron.nvim",
  config = function()
    local iron = require("iron.core")

    iron.setup {
        ...
      keymaps = {
         ...
        cr = "<space><cr>",
        ...
      },
    }
}

@roteiro
Copy link

roteiro commented May 7, 2024

jpalardy/vim-slime#297 (comment)
This issue sounds very related and the linked comment has a possible solution in vimscript

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

6 participants