Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 345e944

Browse files
committed
Add an option to use tslime so it works in graphical vim
1 parent 79b2bf7 commit 345e944

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,20 @@ By default, the following mappings are enabled :
2121
A cell is similar to MATLAB's cell and is defined as the line ranging from
2222
the previous ## to the next ##
2323

24+
Options
25+
-------
26+
If you set *vimux_pyutils_use_tslime* to 1 in your vimrc, this script will use
27+
tslime instead of vimux. This has the advantage that the script will work
28+
from outside a tmux session (in GVim for example).
29+
30+
Note that tslime has to be configured to target the correct session/pane :
31+
32+
let g:tmux_sessionname='0'
33+
let g:tmux_windowname='./ipython.sh'
34+
let g:tmux_panenumber='0'
35+
36+
let g:vimux_pyutils_use_tslime=1
37+
2438
Difference with vim-ipython
2539
---------------------------
2640
Note that if you want more advanced integration with IPython (using the new

ftplugin/python/pyutils.vim

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ if !has('python')
22
finish
33
endif
44

5+
if !exists("g:vimux_pyutils_use_tslime")
6+
let g:vimux_pyutils_use_tslime=0
7+
endif
8+
59
python << endpython
610
import re
711

@@ -43,8 +47,15 @@ def run_tmux_python_chunk():
4347
#vim.command(':call VimuxRunCommand("\n--\n", 0)')
4448

4549
# 2. With cpaste (better, only one command, but rely on system clipboard)
46-
set_register('+', lines)
47-
vim.command(':call VimuxRunCommand("%paste\n", 0)')
50+
51+
# Global variable can be used to switch between vimux and tslime
52+
if vim.eval("g:vimux_pyutils_use_tslime") == "1":
53+
vim.command(':call Send_to_Tmux("\%cpaste\n")')
54+
vim.command(':call Send_to_Tmux("%s")' % lines)
55+
vim.command(':call Send_to_Tmux("\n--\n")')
56+
else:
57+
set_register('+', lines)
58+
vim.command(':call VimuxRunCommand("%paste\n", 0)')
4859

4960
# 3. Directly send the raw text to vimux. This require that we add
5061
# indentation to blank lines : otherwise, this will break the input if

0 commit comments

Comments
 (0)