Fix compatibility of python for vimshell.vim
Refactor code (lightly)
This commit is contained in:
parent
850c04525d
commit
44c428928d
@ -1,3 +1,6 @@
|
|||||||
|
"TODO: Branch python2 and python3
|
||||||
|
"TODO: DRY
|
||||||
|
|
||||||
let g:repl#default_filetype_repl = get(g:, 'repl_filetype_repl', {
|
let g:repl#default_filetype_repl = get(g:, 'repl_filetype_repl', {
|
||||||
\ 'haskell' : {
|
\ 'haskell' : {
|
||||||
\ 'repl' : 'ghci',
|
\ 'repl' : 'ghci',
|
||||||
@ -6,6 +9,10 @@ let g:repl#default_filetype_repl = get(g:, 'repl_filetype_repl', {
|
|||||||
\ 'ruby' : {
|
\ 'ruby' : {
|
||||||
\ 'repl' : 'irb',
|
\ 'repl' : 'irb',
|
||||||
\ 'opt' : '--simple-prompt -r'
|
\ 'opt' : '--simple-prompt -r'
|
||||||
|
\ },
|
||||||
|
\ 'python' : {
|
||||||
|
\ 'repl' : 'python',
|
||||||
|
\ 'opt' : '-i'
|
||||||
\ }
|
\ }
|
||||||
\})
|
\})
|
||||||
|
|
||||||
@ -20,21 +27,20 @@ function! Repl()
|
|||||||
call ReplPython()
|
call ReplPython()
|
||||||
elseif &filetype == 'scala'
|
elseif &filetype == 'scala'
|
||||||
echohl Error
|
echohl Error
|
||||||
echo 'Sorry, this filetype is not supporrted'
|
echo "Sorry, repl.vim didn't support this filetype"
|
||||||
echohl None
|
echohl None
|
||||||
"call ReplScala()
|
"call ReplScala()
|
||||||
elseif &filetype == 'clojure'
|
elseif &filetype == 'clojure'
|
||||||
echohl Error
|
echohl Error
|
||||||
echo 'Sorry, this filetype is not supporrted'
|
echo "Sorry, repl.vim didn't support this filetype"
|
||||||
echohl None
|
echohl None
|
||||||
"call ReplClojure()
|
"call ReplClojure()
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:CallVimShell(args)
|
"function! s:CallVimShell(args)
|
||||||
execute ':VimShellInteractive' a:args
|
" execute ':VimShellInteractive' a:args
|
||||||
endfunction
|
"endfunction
|
||||||
|
|
||||||
|
|
||||||
function! ReplRuby()
|
function! ReplRuby()
|
||||||
" Setting up the obj file for the current file
|
" Setting up the obj file for the current file
|
||||||
@ -88,12 +94,21 @@ function! ReplErlang()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ReplPython()
|
function! ReplPython()
|
||||||
let l:currentFile = expand('%:r') " current file without the extension
|
" Setting up the file for the current file
|
||||||
let l:args = 'python -'
|
if &modified
|
||||||
call s:CallVimShell(l:args)
|
" Create new file temporary
|
||||||
call vimshell#interactive#send_string(
|
let l:module_file = tempname() . '.py'
|
||||||
\ "from " . l:currentFile . " import *\n",
|
call writefile(getline(1, expand('$')), l:module_file)
|
||||||
\1)
|
else
|
||||||
|
let l:module_file = expand('%:p')
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:repl = exists('g:repl_filetype_repl.python') ? g:repl_filetype_repl.python['repl']
|
||||||
|
\ : g:repl#default_filetype_repl.python['repl']
|
||||||
|
let l:opt = exists('g:repl_filetype_repl.python') ? g:repl_filetype_repl.python['opt']
|
||||||
|
\ : g:repl#default_filetype_repl.python['opt']
|
||||||
|
let l:args = printf('%s %s %s', l:repl, l:opt, l:module_file)
|
||||||
|
execute ':VimShellInteractive' l:args
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"function! ReplScala()
|
"function! ReplScala()
|
||||||
|
Reference in New Issue
Block a user