forked from jpalardy/vim-slime
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathslime.vim
More file actions
18 lines (15 loc) · 793 Bytes
/
slime.vim
File metadata and controls
18 lines (15 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
let g:slime_config_defaults["python_ipython"] = 0
let g:slime_config_defaults["dispatch_ipython_pause"] = 100
function! _EscapeText_python(text)
if slime#config#resolve("python_ipython") && len(split(a:text,"\n")) > 1
return ["%cpaste -q\n", slime#config#resolve("dispatch_ipython_pause"), a:text, "--\n"]
else
let empty_lines_pat = '\(^\|\n\)\zs\(\s*\n\+\)\+'
let no_empty_lines = substitute(a:text, empty_lines_pat, "", "g")
let dedent_pat = '\(^\|\n\)\zs'.matchstr(no_empty_lines, '^\s*')
let dedented_lines = substitute(no_empty_lines, dedent_pat, "", "g")
let except_pat = '\(elif\|else\|except\|finally\)\@!'
let add_eol_pat = '\n\s[^\n]\+\n\zs\ze\('.except_pat.'\S\|$\)'
return substitute(dedented_lines, add_eol_pat, "\n", "g")
end
endfunction