Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to use cpaste for IPython #68

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ You can use [Python][] and [CoffeeScript][] hooks as examples.
- `g:slimux_pane_format` customize the formatting of the panes, see the FORMATS section in `man tmux`.
The string "`#{pane_id}: `" is always prepended to the format so Slimux can identify the selected pane.

- `g:slimux_python_ipython = 1` use `%cpaste` of [IPython](http://ipython.org/) to avoid indentation errors.
You need to set this to `1` if you use IPython for an interactive Python session.


## Other Vim Slime plugins

Expand Down
5 changes: 5 additions & 0 deletions ftplugin/python.vim
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ function! SlimuxEscape_python(text)
return ""
endif

"" Use IPython's '%cpaste' if the option set
if exists('g:slimux_python_ipython')
return no_empty_lines
endif

"" Process line by line and insert needed linebreaks
let l:non_processed_lines = split(no_empty_lines,"")
let l:processed_lines = [l:non_processed_lines[0]]
Expand Down
8 changes: 8 additions & 0 deletions plugin/slimux.vim
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,16 @@ function! s:Send(tmux_packet)
endif

let named_buffer = s:tmux_version >= '2.0' ? '-b Slimux' : ''
if exists('g:slimux_python_ipython')
Copy link
Contributor

@lotabout lotabout May 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually think this option is python related. Thus it should not be included in slimux.vim, instead, use hooks for python file type.
Ex: #38 (comment)

call system(g:slimux_tmux_path . ' load-buffer ' . named_buffer . ' -', '%cpaste')
call system(g:slimux_tmux_path . ' paste-buffer ' . named_buffer . ' -t ' . target)
endif
call system(g:slimux_tmux_path . ' load-buffer ' . named_buffer . ' -', text)
call system(g:slimux_tmux_path . ' paste-buffer ' . named_buffer . ' -t ' . target)
if exists('g:slimux_python_ipython')
call system(g:slimux_tmux_path . ' load-buffer ' . named_buffer . ' -', '--')
call system(g:slimux_tmux_path . ' paste-buffer ' . named_buffer . ' -t ' . target)
endif

if type == "code"
call s:ExecFileTypeFn("SlimuxPost_", [target])
Expand Down