vim-slime icon indicating copy to clipboard operation
vim-slime copied to clipboard

Line breaks are randomly correct under Windows 10 and iPython.

Open ubaldot opened this issue 3 years ago • 5 comments

Hi all, I am running a split window where I have the editor on top and a Windows powershell running iPython in the bottom. The problem is that when I vim-slime then the <CR> is randomly correct.
The below picture is an example of what happens by <C-c><C-c>-ing several times in a row.

image

As you see in In [22]: and In [23]: it worked, then it didn't work any longer. Then, it eventually worked again, then it won't work, and so on and so forth. All completely random.

I have tried to tweak ftplugin/python.slime.vim by changing line 8 with e.g. return ["%cpaste -q","\n",a:text,"--","\n"] or by adding some delay, but the random behavior is still there. As @jpalardy suggested here such a behavior sounds like a race condition but I have no idea how to solve it, nor where to start (that goes way beyond my competences).

My setup:

Windows 10 with Vim (32 bit)

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Sep 21 2021 22:13:38)
MS-Windows 32-bit console version
Included patches: 1-3452
Compiled by appveyor@APPVYR-WIN
Huge version without GUI.  Features included (+) or not (-):
+acl                +ex_extra           +multi_lang         -tag_any_white
+arabic             +extra_search       +mzscheme/dyn       +tcl/dyn
+autocmd            -farsi              -netbeans_intg      +termguicolors
+autochdir          +file_in_path       +num64              +terminal
+autoservername     +find_in_path       +packages           -termresponse
-balloon_eval       +float              +path_extra         +textobjects
+balloon_eval_term  +folding            +perl/dyn           +textprop
-browse             -footer             +persistent_undo    -tgetent
++builtin_terms     +gettext/dyn        +popupwin           +timers
+byte_offset        -hangul_input       -postscript         +title
+channel            +iconv/dyn          +printer            -toolbar
+cindent            +insert_expand      +profile            +user_commands
+clientserver       +ipv6               +python/dyn         +vartabs
+clipboard          +job                +python3/dyn        +vertsplit
+cmdline_compl      +jumplist           +quickfix           +virtualedit
+cmdline_hist       +keymap             +reltime            +visual
+cmdline_info       +lambda             +rightleft          +visualextra
+comments           +langmap            +ruby/dyn           +viminfo
+conceal            +libcall            +scrollbind         +vreplace
+cryptv             +linebreak          +signs              +vtp
+cscope             +lispindent         +smartindent        +wildignore
+cursorbind         +listcmds           -sodium             +wildmenu
+cursorshape        +localmap           +sound              +windows
+dialog_con         +lua/dyn            +spell              +writebackup
+diff               +menu               +startuptime        -xfontset
+digraphs           +mksession          +statusline         -xim
-dnd                +modify_fname       -sun_workshop       -xpm_w32
-ebcdic             +mouse              +syntax             -xterm_save
+emacs_tags         -mouseshape         +tag_binary
+eval               +multi_byte_ime/dyn -tag_old_static

My _vimrc:

set encoding=utf-8
set nu
set tabstop=4 softtabstop=4
set shiftwidth=4
set expandtab
set smartindent
set nobackup
set backspace=indent,eol,start
set nocompatible              " required
set clipboard=unnamed
set laststatus=2
set statusline=%f "tail of the filename
set incsearch " for displaying while searching
set smartcase
set hidden
set noswapfile

" Set terminal with 256 colors
set termguicolors
colorscheme desert
set nofoldenable
set foldmethod=syntax
set foldlevelstart=20

" Set fonts for gvim
if has("gui_win32")
    set guifont=Consolas:h11:cANSI
endif

" Automatically open VimGoodies.txt 
"autocmd VimEnter * edit ~/VimGoodies.txt | tabnew

" Buffer management
nnoremap <leader>b :ls<CR>:b
map <C-Left> :bnext<CR>
map <C-Right> :bprev<CR>

" Open terminal below all splits
" For Cygwin
" cabbrev bterm bo term
" For Windows
cabbrev bterm bo terminal powershell

" ALE completion stuff to be set before the plugin.
let g:ale_completion_enabled = 1
let g:ale_completion_autoimport = 1

" --- VUNDLE PLUGIN STUFF BEGIN --------
filetype off                  " required
" Vundle plugin manager
"set the runtime path to include Vundle and initialize
set rtp+=C:/Users/yt75534/vimfiles/bundle/Vundle.vim
 call vundle#begin('C:/Users/yt75534/vimfiles/bundle')
" let Vundle manage Vundle, required
" add all your plugins here (note older versions of Vundle
" used Bundle instead of Plugin)
Plugin 'gmarik/Vundle.vim'
Plugin 'tmhedberg/SimpylFold.vim'
Plugin 'dense-analysis/ale'
Plugin 'ctrlpvim/ctrlp'
Plugin 'nvie/vim-flake8'
Plugin 'davidhalter/jedi-vim'
Plugin 'jpalardy/vim-slime'
Plugin 'jupyter-vim/jupyter-vim'
call vundle#end()            " required
filetype plugin indent on    " required for Vundle
" ---- VUNDLE PLUGIN STUFF END ----------

" ---- Plugin tweak ------
" SimylFold tweak
" Enable folding with the spacebar
nnoremap <space> za

" vim-slime fix paste issues in ipython
let g:slime_python_ipython = 1
let g:slime_target = "vimterminal"
let g:slime_cell_delimiter = "# %%"
" nmap <C-c><C-v> :call slime#send_cell()<CR>:SlimeSend0 "\r"<CR>
"nmap <C-c><C-x> :call slime#send(getline(".") . "\r"<CR>)
nmap <C-c><C-v> :SlimeSendCurrentLine<CR>
nmap <C-c><C-x> :SlimeSend0<CR>

" vim-jupyter setup
set pythonthreedll=python38.dll
set pythonthreehome=~/Anaconda3
let g:jupyter_mapkeys = 0
let maplocalleader = ','

" Set jedi-vim
" To use Anaconda python
let g:jedi#environment_path = 'C:\Users\yt75534\Anaconda3\python.exe'
" To avoid that it opens the doc while autocompleting
autocmd FileType python setlocal completeopt-=preview
let g:jedi#show_call_signatures = "2" " To avoid showing call signature while typing. To show it, set this to 1.

" Ctrlp stuff
set wildignore+=*\\_out\\*,*\\Cantata\\*
" ctrlp search from current director
let g:ctrlp_cmd='CtrlP :pwd'
let g:ctrlp_max_files=0


"   ALE linter stuff
let g:ale_linters = {'c': ['clangtidy','clangd'],'python':['flake8']}
let g:ale_fixers = {
\   'c':['astyle','clangtidy','remove_trailing_lines', 'trim_whitespace'], 
\}
let g:ale_c_clangtidy_checks = ['*']
let g:ale_c_clangtidy_extra_options = '--extra-arg=-I --extra-arg=C:\Devtools\Install\Cygwin\3.0.7\usr\include --extra-arg=-I --extra-arg=C:\PE_Builds\sw-ecu\BSW\_out\P_AMTG_MC_TEA2P\bin\all_inc' " change header file path if needed
map <C-a><C-a> :ALEGoToDefinition<CR>
map <C-a><C-z> :ALEFindReferences<CR>

" Matlab syntax stuff. To use the code checker use :make
source $VIMRUNTIME/macros/matchit.vim
filetype indent on
autocmd BufEnter *.m    compiler mlint

syntax on
" When using iPython to avoid that shift space gives 32;2u
tnoremap <S-space> <space>

" To have nice colors during autocompletion
hi Pmenu guibg=lightgray guifg=black
hi PmenuSel guibg=darkgray guifg=gray

" In case you use a terminal you want the same
hi Pmenu ctermbg=lightgray ctermfg=black
hi PmenuSel ctermbg=darkgray ctermfg=gray

My iPython version:

Python 3.8.8 (default, Apr 13 2021, 15:08:07) [MSC v.1916 32 bit (Intel)]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.22.0 -- An enhanced Interactive Python. Type '?' for help.

ubaldot avatar Nov 10 '21 12:11 ubaldot

hi @Barzi2001

Thank you for opening the separate issue for this ^

It's a new day, and I have new ideas:

  • did you try reducing your config to a minimum (removing, temporarily, other plugins and settings) and see if it still behave the same?
  • did you try the same config, but on linux or macos? (if you have access)

jpalardy avatar Nov 10 '21 16:11 jpalardy

Hello!

I finally found some time to test it. I tried with the following minimum _vimrc

set encoding=utf-8
set nu
set tabstop=4 softtabstop=4
set shiftwidth=4
set expandtab
set smartindent
set nobackup
set backspace=indent,eol,start
set nocompatible              " required
set clipboard=unnamed
set laststatus=2
set statusline=%f "tail of the filename
set incsearch " for displaying while searching
set smartcase
set hidden
set noswapfile

cabbrev bterm bo terminal powershell

" --- VUNDLE PLUGIN STUFF BEGIN --------
filetype off                  " required
set rtp+=C:/Users/yt75534/vimfiles/bundle/Vundle.vim
call vundle#begin('C:/Users/yt75534/vimfiles/bundle')
Plugin 'gmarik/Vundle.vim'
Plugin 'jpalardy/vim-slime'
call vundle#end()            " required
filetype plugin indent on    " required for Vundle
" ---- VUNDLE PLUGIN STUFF END ----------

" vim-slime fix paste issues in ipython
let g:slime_python_ipython = 1
let g:slime_target = "vimterminal"
let g:slime_cell_delimiter = "# %%"
nmap <C-c><C-v> :SlimeSendCurrentLine<CR>
nmap <C-c><C-x> :SlimeSend0<CR>

and the problem persists.

Unfortunately I don't have any Linux or MacOs machine.

Any other hints are most than welcome ofc :)

ubaldot avatar Nov 22 '21 12:11 ubaldot

UPDATE: I have updated my Anaconda environment and I am now running IPython 8.2.2. The command :SlimeSendCurrentLine seems to work perfectly now, but there is still the problem E471 Argument required when sending a code-cell, see https://github.com/jpalardy/vim-slime/issues/324

ubaldot avatar Apr 11 '22 08:04 ubaldot

whoah…

jpalardy avatar Apr 11 '22 16:04 jpalardy

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 13 '22 06:08 stale[bot]