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

Cannot send multiple lines with ctr #63

Closed
dahlbaek opened this issue Sep 16, 2017 · 7 comments
Closed

Cannot send multiple lines with ctr #63

dahlbaek opened this issue Sep 16, 2017 · 7 comments

Comments

@dahlbaek
Copy link

dahlbaek commented Sep 16, 2017

Thank you for writing this plugin, and for making it available!

I encountered a problem when sending multiple lines to the REPL. Minimal setup:
minimalvimrc:

set nocompatible

let &rtp  = '~/.config/nvim/plugged/iron.nvim,' . &rtp

tnoremap <Esc> <C-\><C-N>

filetype plugin indent on
syntax enable

test.py:

def test():
    return 42

test()

If I open nvim with nvim -u minimalvimrc +'IronRepl' test.py and type <Esc><C-W>kctrG, I see the following in the REPL window

In [1]: 0~def test():
   ...:         return 42
  File "<ipython-input-somenumber>", line 1
    0~def test():
     ^
SyntaxError: invalid syntax



In [2]:

In [2]: test()1~
  File "<ipython-input-somenumber>", line 1
    test()1~
          ^
SyntaxError: invalid syntax

Thus, it seems that there is an extra 0~ inserted at the beginning of the lines I send, and an extra 1~ at the end, which of course confuses python. If I only send a single line, this problem does not occur.

I'm am on Ubuntu 16.04, with Python 2.7.12, IPython 2.4.1 and nvim v0.2.0. The same thing happens if I use :IronPromptCommand and pick IPython3, in which case I am on Python 3.5.2.

I hope this is just due to some simple misconfiguration on my end!

@dahlbaek
Copy link
Author

I made some naive changes to the file iron.nvim/rplugin/python3/iron/repls/python.py, and now it seems to be working. I don't know if my changes break some other functionality.

https://github.com/dahlbaek/iron.nvim

@hkupty
Copy link
Collaborator

hkupty commented Sep 18, 2017

Sory for taking long to answer..

The fix you implemented might indeed actually break for some/most clients. This is actually strange since I use python frequently (i.e. for testing neovim plugins) and iron behaves correctly.

Could you print the neovim interface (if any), python3 neovim package version? I'll try to reproduce that on my side..

@dahlbaek
Copy link
Author

Thank you for taking an interest in my issue!

I noticed that if I use ipython (the default) or ipython3 with IronPromptCommand, then the indentation also ends up funny, while the indentation is fine if I use python or python3. When using ipython, I get the comment If you want to paste code into IPython, try the %paste and %cpaste magic functions.

I am not sure I know what you mean by neovim interface, I am using the stable neovim for Ubuntu.

Here is the output of :CheckHealth, in case that is useful (I removed the parts that I do not think are useful):

========================================================================
## Configuration
  - SUCCESS: no issues found

## Performance
  - SUCCESS: Build type: RelWithDebInfo

## Remote Plugins
  - SUCCESS: Up to date

## terminal
  - INFO: key_backspace (kbs) terminfo entry: key_backspace=\177
  - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~

health#provider#check
========================================================================
## Clipboard (optional)
  - SUCCESS: Clipboard tool found: xsel

## Python 2 provider (optional)
  - INFO: Using: g:python_host_prog = "usr/bin/python"
  - INFO: Executable: /usr/bin/python
  - INFO: Python2 version: 2.7.12
  - INFO: python-neovim version: 0.1.13
  - SUCCESS: Latest python-neovim is installed: 0.1.13

## Python 3 provider (optional)
  - INFO: Using: g:python3_host_prog = "/usr/bin/python3"
  - INFO: Executable: /usr/bin/python3
  - INFO: Python3 version: 3.5.2
  - INFO: python3-neovim version: 0.1.13
  - SUCCESS: Latest python3-neovim is installed: 0.1.13

Maybe the output of nvim --version is also useful?

Build type: RelWithDebInfo
Compilation: /usr/bin/x86_64-linux-gnu-gcc -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -DDISABLE_LOG -Wdate-time -D_FORTIFY_SOURCE=2 -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -DDISABLE_LOG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -I/build/neovim-LpFVCC/neovim-0.2.0/build/config -I/build/neovim-LpFVCC/neovim-0.2.0/src -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/build/neovim-LpFVCC/neovim-0.2.0/build/src/nvim/auto -I/build/neovim-LpFVCC/neovim-0.2.0/build/include
Compiled by pkg-vim-maintainers@lists.alioth.debian.org

Optional features included (+) or not (-): +acl   +iconv    +jemalloc +tui      
For differences from Vim, see :help vim-differences

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

@hkupty
Copy link
Collaborator

hkupty commented Sep 20, 2017

It seems that, for some reason, your repl isn't correctly parsing the '\x1b[200~' and '\x1b[201~' escape characters. What terminal are you running (though I suspect it shouldn't interfere)? By interface I mean GUI, such as neovim-qt or gonvim, but you're using it straight from the terminal it seems..

@hkupty
Copy link
Collaborator

hkupty commented Sep 20, 2017

Nonetheless, I'll try to implement those block pastes with %cpaste and -- which seems to be more reliable, though the current setting works for me both on neovim-qt and using alacritty as terminal. Not sure about ptpython/ptipython. I'll leave those as they are now since they seem to be working pretty well..

hkupty added a commit that referenced this issue Sep 20, 2017
@dahlbaek
Copy link
Author

dahlbaek commented Sep 20, 2017

I actually just got ipython working, by upgrading from 2.4.1 to 6.2.0 (ahem, slightly embarrassing). And now iron.nvim automatically launches ipython/python3 instead of ipython/python2. Maybe there is something else I should make sure to update with pip to make python/python3 work without ipython?

I am using nvim from gnome-terminal on ubuntu 16.04. For the sake of it, I tried xterm just now, and it behaves exactly the same.

In any case, I am happy that just ipython is working for now! Let me know if I can help with anything.

@hkupty
Copy link
Collaborator

hkupty commented Sep 21, 2017

Glad to know that it's working now!
Not really sure how to handle the issue with the python executable.
I'm planning to revamp this REPL selection and hopefully this will be sorted out in the future.

@hkupty hkupty closed this as completed Mar 14, 2018
hkupty added a commit that referenced this issue Jul 4, 2018
hkupty added a commit that referenced this issue Apr 13, 2023
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

2 participants