kassio/neoterm

Python REPL error

strboul opened this issue · 8 comments

Describe the bug
Get an error when using :TREPLSendLine from a Python file:

Error detected while processing function neoterm#repl#line[2]..316[4]..neoterm#repl#python#exec[11]..278
[4]..283:
line    1:
E900: Invalid channel id
Press ENTER or type command to continue

Most likely, the bug is introduced in this PR #273

Versions (please complete the following information):

  • OS: macOS
  • neoterm commit sha1 c59657b
  • NVIM v0.4.3

@strboul can you give an example, please?
Do you have a custom g:neoterm_repl_python?

I don't have a custom g:neoterm_repl_python option. Here's the neoterm related config in my init.vim:

let g:neoterm_default_mod="belowright"
let g:neoterm_size=16
let g:neoterm_autoscroll=1
let g:neoterm_direct_open_repl=1
" Calling :Tclose or :Ttoggle kills the terminal
let g:neoterm_keep_term_open=0
" Set REPLs
if executable("radian")
  let g:neoterm_repl_r="radian"
endif
" send current line and move down
nnoremap <silent><leader><cr> :TREPLSendLine<cr>j
" send current selection
" ('> goes to the last selected Visual area in the current buffer)
vnoremap <silent><leader><cr> :TREPLSendSelection<cr>'>j
" toggle terminal
nnoremap <silent><c-t><c-t> :Ttoggle<CR>
tnoremap <silent><c-t><c-t> <C-\><C-n>:Ttoggle<CR>

I'm not a python dev, the simple hello world worked on my machine. Can you give me a longer piece of code for tests, please?

I cannot start a python REPL (via :Tnew or :Ttoggle) from any file ending with .py; instead, it creates an empty buffer. Maybe neoterm cannot find the python in my paths?

command -v python3
# /usr/local/bin/python3
command -v python
# /usr/bin/python
command -v ipython3
# /usr/local/bin/ipython3
command -v ipython
# /usr/local/bin/ipython

Edit: No luck when I add the let g:neoterm_repl_python="ipython3" line to my init.vim.

Edit2: The problem is only with the Python REPL. Other REPLs are working.

Never used the direct_open_repl setting, but I can reproduce the error.
I will try to fix this.

Edit: The error has apparently occurred with commit f6c6ce0Y. I'll take a closer look at that tomorrow.

Edit2:

function! s:vim.new(opts)
  let l:opts = {
        ...
        \ }
  if g:neoterm_direct_open_repl
    return term_start(g:neoterm_repl_command, l:opts) "<-- HERE: g:neoterm_repl_command[0]
  else
    return term_start(g:neoterm_shell, l:opts)
  end
endfunction

Since the variable g: neoterm_repl_command has changed from a string to a list, I thought that g: neoterm_repl_command[0] would solve the problem. Yeah, it does not ...
I would like to find out which values are hidden behind l:opts and how term_start() works.
I have set a breakpoint within the function. With :debug Tnew I would have expected a stop at the breakpoint. But the function does not seem to be executed at all. I'm trying to understand the execution chain, but I'm still struggling with the debugger. @kassio, can you help?

I'm having this issue all of a sudden as well. Fixed by reverting to e011fa1

Oh man I actually already had the bug ... I just didn't notice that there is both a term#vim and a term#neovim. I will open a pull request.

It should be fixed now, let me know if you have any other problem.