kassio / neoterm

Wrapper of some vim/neovim's :terminal functions.
Other
1.32k stars 117 forks source link

Does not do <CR>? after cmd in Windows: bug? #171

Closed yelled1 closed 7 years ago

yelled1 commented 7 years ago

After a very happy installation on the Ubuntu, I am attempting to get it done on Window. I am NOT sure if this is neoterm bug or neovim, but I think it's more likely neoterm's I have

if has("win32") let g:neoterm_repl_python = 'c:/Bin/Miniconda3/Scripts/ipython' let g:neoterm_repl_julia = 'C:\tools\Julia-0.6.0\bin\julia.exe' elseif has("unix") let g:neoterm_repl_julia = '/opt/julia/bin/julia' let g:neoterm_repl_python = '/opt/miniconda3/envs/SPk/bin/ipython' "let g:neoterm_repl_scala = '/usr/bin/sbt console' endif

and import pandas as pd # 1st line of python prg

Microsoft Windows [Version 10.0.16299.19] (c) 2017 Microsoft Corporation. All rights reserved. F:\DFS\Prj\LearnPy\Pandas>ipython --no-autoindentimport pandas as pd (**hangs**)

then it hangs I have to come down to hit enter (obviously fails)

So, I do :T ipython from the prompt Microsoft Windows [Version 10.0.16299.19] (c) 2017 Microsoft Corporation. All rights reserved. F:\DFS\Prj\LearnPy\Pandas>ipython(hangs again) then it hangs I have to come down to hit enter to get Python 3.6.3 |Anaconda, Inc.| (default, Oct 27 2017, 12:22:41) [MSC v.1900 64 bit (AMD64)] Type 'copyright', 'credits' or 'license' for more information IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help. In [1]:

and when I execute lines via nnoremap <silent> <C-CR> :TREPLSendLine<CR>j0

I get back below in repl In [1]: c:/Bin/Miniconda3/Scripts/ipython ...: url='https://raw.githubusercontent.com/justmarkham/DAT8/master/data/chipotle.tsv' ...: chipo = pd.read_csv(url, sep='\t') ...: chipo.head(3) ...: chipo.item_price = chipo.item_price.map(lambda x: float(x[1:])) ...: tmp = chipo.filter(items=['1']) ...: Not sure why window's behavior is diff than linux

yelled1 commented 7 years ago

Seems like a merge with issue :T or TREPLSendline/SendSelection does not send the Enter Key to terminal #155 Likely something todo with DOS uses carriage return and line feed ("\r\n") as a line ending, which Unix uses just line feed ("\n") issue. likely need g:neoterm_eol like g:neoterm_eof

:terminal E:\bin\bash\bash.exe do open up bash terminal

kassio commented 7 years ago

Have you tried to change the g:neoterm_eof to \<cr> or something like that? This should fix the problem.

kassio commented 7 years ago

The commit that added g:neoterm_eof for reference: https://github.com/kassio/neoterm/commit/a24d3704131e48e24c974dc9227973fcf850c336.

yelled1 commented 7 years ago

Doh! My mind did not click and eof was terminal file eof. if has ("win32") let g:neoterm_eof = "\r" endif works perfectly. Thank you (again & again)! Closing this,

Below is FYI only But I am not rejoicing yet. Now I have utf8 problem ?[?25l?[0m?[?7l?[0m?[J?[0;32mIn [?[0;92;1m1?[0;32m]: ?[8D?[8C?[?7h?[0m?[?12l?[?25h This fails under :terminal but works well on windows cmd.exe launched from W-r (Super-r) cmd So, this is definitely neovim problem - I will attempt to find the answer or ask there & link the answer. Bugged u enough; so, pls post if you know it on top of ur head.

already tried set termencoding=utf8

Attempted on console C:\tools\Julia\bin>julia I see no colors () | A fresh approach to technical computing () | () () | Documentation: https://docs.julialang.org | |_ | Type "?help" for help. | | | | | | |/ ` | | | | || | | | (| | | Version 0.6.0 (2017-06-19 13:05 UTC) / |_'|||_'_| | Official http://julialang.org/ release |/ | x86_64-w64-mingw32

julia>

C:\tools\Julia\bin>cd \bin\Miniconda3\envs\wSPk\Scripts\

C:\Bin\Miniconda3\envs\wSPk\Scripts>ipython Python 3.6.3 |Anaconda, Inc.| (default, Oct 15 2017, 03:27:45) [MSC v.1900 64 bit (AMD64)] Type 'copyright', 'credits' or 'license' for more information IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.

?[?25l?[0m?[?7l?[0m?[J?[0;32mIn [?[0;92;1m1?[0;32m]: ?[8D?[8C?[?7h?[0m?[?12l?[?25h

yelled1 commented 7 years ago

Strictly FYI: One more issue to raise, just incase anyone gets totally frustrated as I am. The solution w/ eof works if I launch nvim from cmder; however, I get into utf8 issue If you launch from cmd or window-explorer then I have no utf8 issue; however, I get to the eof prob again. Not neoterm issue but some kind of shell/terminal inherited prob. So, when I find answer, then I will post here for ref.

yelled1 commented 7 years ago

This is becoming an extremely complex problem. Even my ubuntu box is having prb. The prob lies in ipython and terminal rather than neoterm. Not sure it can be fixed though. When I set repl on ubuntu, the visual selection no longer works it turns into a line by line: inoremap :TREPLSendLine even I send a whole selection only 1st line executes. I believe this is because a newline is entered after 1st line. When I use bash as g:neoterm_repl_python and launch python from it. It does not even register as a command. A simple solution that might work from neo term side is to strip all newline character & replace with a designated character eof, but this is NOT quite a neoterm problem. So, I only suggest. The real solution is obviously to fix the ipython, but, as emacs' long long ipython elpy script shows, this will likely turn into a hack that requires another plug in from neovim's side. This is not surprising with white space dependent lang like python. Darn, I thought I had a perfect env.

In windows, as described above, it depends on how nvim is launched. if has("win32") "let g:neoterm_direct_open_repl = 1 " causes file directory NOT found error "let g:neoterm_auto_repl_cmd = 1 "let g:neoterm_repl_command = 'E:/Bin/bash/bash.exe' set termencoding=utf8 let g:neoterm_repl_python = 'C:/Bin/Miniconda3/envs/wSPk/Scripts/ipython.exe' "--no-autoindent' let g:neoterm_repl_julia = 'C:/tools/Julia/bin/julia.exe' let g:neoterm_eof = "\r" elseif has("unix") let g:neoterm_repl_julia = '/opt/julia/bin/julia' let g:neoterm_repl_python = '/opt/miniconda3/envs/SPk/bin/ipython' " --no-autoindent' "let g:neoterm_repl_scala = '/usr/bin/sbt console' endif

yelled1 commented 7 years ago

Ok, here's the skinny on this problem.

  1. DOn't use i_python! Use python instead. Now ubuntu works fine. Virtual env one works fine. ipython is a mess in terms of consistency between windows & linux.
  2. Windows, on the other hand, cannot send multiple lines. Type "help", "copyright", "credits" or "license" for more information.

    import pandas as pdimport numpy as np File "", line 1 import pandas as pdimport numpy as np Above was supposed to be 2 lines import pandas as pd import numpy as np it's fusing it together because nvim only prob use '\n' rather than '\r\n'

  3. code below, if I just take for i in def test(x): for i in range(x): print(i) I get IndentationError: unexpected indent
    for i in range(x): print(i)

    File "", line 1 for i in range(x): print(i) ^ IndentationError: unexpected indent

    So, as suspected the white lines do matter & requires quite a bit of regex coding to fix this. Until this is done, do NOT use nvim for python coding w/ repl. My scala code, however, is working fine.

EtiamNullam commented 4 years ago

Doh! My mind did not click and eof was terminal file eof.

if has ("win32")
let g:neoterm_eof = "\r"
endif

works perfectly. Thank you (again & again)!

I think it should be mentioned in README.md or docs. Maybe even default value should be different for Windows.