diff --git a/README.rst b/README.rst index b79ea68..962e43e 100644 --- a/README.rst +++ b/README.rst @@ -3,7 +3,7 @@ Vimteractive ============ :vimteractive: send commands from text files to interactive programs via vim :Author: Will Handley -:Version: 2.7.0 +:Version: 2.7.1 :Homepage: https://github.com/williamjameshandley/vimteractive :Documentation: ``:help vimteractive`` diff --git a/autoload/vimteractive.vim b/autoload/vimteractive.vim index 2d9962f..134e45d 100644 --- a/autoload/vimteractive.vim +++ b/autoload/vimteractive.vim @@ -103,11 +103,19 @@ function! vimteractive#sendlines(lines) execute ":b " . l:current_buffer endif - if get(g:vimteractive_bracketed_paste, l:term_type, g:vimteractive_bracketed_paste_default) - call term_sendkeys(b:vimteractive_connected_term,"[200~" . a:lines . "[201~\n") + if match(a:lines, '\n') >= 0 + if has_key(g:vimteractive_brackets, l:term_type) + let open_bracket = g:vimteractive_brackets[l:term_type][0] + let close_bracket = g:vimteractive_brackets[l:term_type][1] + else + let open_bracket = g:open_bracketed_paste + let close_bracket = g:close_bracketed_paste + endif + let b:lines = open_bracket . a:lines . close_bracket . "\" else - call term_sendkeys(b:vimteractive_connected_term, a:lines . "\n") + let b:lines = a:lines . "\" endif + call term_sendkeys(b:vimteractive_connected_term, b:lines) endfunction " Start a vimteractive terminal diff --git a/plugin/vimteractive.vim b/plugin/vimteractive.vim index 4858707..e4b0765 100644 --- a/plugin/vimteractive.vim +++ b/plugin/vimteractive.vim @@ -28,39 +28,38 @@ endif if !has_key(g:, 'vimteractive_commands') let g:vimteractive_commands = { } endif +if !has_key(g:, 'vimteractive_brackets') + let g:vimteractive_brackets = { } +endif + +let g:open_bracketed_paste = "[200~" +let g:close_bracketed_paste = "[201~" + let g:vimteractive_commands.ipython = 'ipython --matplotlib --no-autoindent --logfile="-o "' let g:vimteractive_commands.python = 'python' +let g:vimteractive_brackets.python = ['',''] let g:vimteractive_commands.bash = 'bash' let g:vimteractive_commands.zsh = 'zsh' let g:vimteractive_commands.julia = 'julia' let g:vimteractive_commands.maple = 'maple -c "interface(errorcursor=false);"' let g:vimteractive_commands.clojure = 'clojure' +let g:vimteractive_brackets.clojure = ['',''] let g:vimteractive_commands.apl = 'apl' +let g:vimteractive_brackets.apl = ['',''] let g:vimteractive_commands.R = 'R' let g:vimteractive_commands.mathematica = 'math' +let g:vimteractive_brackets.mathematica = ['',''] let g:vimteractive_commands.sgpt = 'sgpt --repl ' +let g:vimteractive_brackets.sgpt = ["\"\"\"\" . g:open_bracketed_paste, g:close_bracketed_paste . "\\"\"\""] let g:vimteractive_commands.gpt = 'gpt --log_file ' +let g:vimteractive_brackets.gpt = ["\\\" . g:open_bracketed_paste, g:close_bracketed_paste . "\\"] " Override default shells for different filetypes if !has_key(g:, 'vimteractive_default_shells') let g:vimteractive_default_shells = { } endif -" If 0, disable bracketed paste escape sequences -if !has_key(g:, 'vimteractive_bracketed_paste_default') - let g:vimteractive_bracketed_paste_default=1 -endif -if !has_key(g:, 'vimteractive_bracketed_paste') - let g:vimteractive_bracketed_paste = { } -endif -let g:vimteractive_bracketed_paste.clojure = 0 -let g:vimteractive_bracketed_paste.python = 0 -let g:vimteractive_bracketed_paste.python2 = 0 -let g:vimteractive_bracketed_paste.python3 = 0 -let g:vimteractive_bracketed_paste.apl = 0 -let g:vimteractive_bracketed_paste.mathematica = 0 - " If present, wait this amount of time in ms when starting term on ^S if !has_key(g:, 'vimteractive_slow_prompt') let g:vimteractive_slow_prompt = { }