neoterm sends previous clipboard content to ipython REPL
adolfocorreia opened this issue · 0 comments
Bug description
Often, when I send text to the ipython REPL using neoterm, the previous content of the clipboard is sent instead of the current line or selected region. I did some research on this on my own and my guess is that ipython reads from the clipboard before neovim is able to finish writing to it. Note that my system is often overloaded and slow due to too many running processes and low CPU/memory specs. Note also that my neovim configuration is not light (40+ installed plugins).
As an indication that this might be the case, I added a sleep
command in the s:ipython_magic_command_for
in python.vim:
function! s:ipython_magic_command_for(command) abort
call setreg('+', a:command, 'l')
sleep 100m
return ['%paste']
endfunction
With this sleep command, I now get the expected behavior most of the time.
Adding a sleep command to the function is probably not the best solution and there might be better workarounds (e.g. reading from the clipboard to check if its content was updated before returning from the function), but I haven't tried anything else.
To Reproduce
These days I have been observing this weird behavior consistently, but I'm not sure how I'd go about it trying to reproduce it on someone else's system. However, my guess is that it has something to do with my computer's overall slowness and overloadedness.
Versions (Issues without this information will take longer to be answered/solved):
- OS: Windows 10
- neoterm commit: master/e78179a9ceb98de8d0c37bdda435a5deab4d5e71
- Neoterm configuration:
let g:neoterm_default_mod = 'vertical'
let g:neoterm_direct_open_repl = 1
let g:neoterm_repl_python = ['ipython --profile=vi']
let g:neoterm_repl_enable_ipython_paste_magic = 1
if g:os ==# 'Linux'
let g:neoterm_shell = 'bash'
endif
- Vim or Neovim
- vim
- neovim
- Version v0.5.1
Additional context
Here is my ipython profile configuration:
## Autoindent IPython code entered interactively.
# Default: True
c.InteractiveShell.autoindent = False
## Shortcut style to use at the prompt. 'vi' or 'emacs'.
# Default: 'emacs'
c.TerminalInteractiveShell.editing_mode = 'vi'