From 850c04525da0365fc209703306a7839bacb11059 Mon Sep 17 00:00:00 2001 From: aiya000 Date: Mon, 14 Dec 2015 14:43:22 +0900 Subject: [PATCH] Add variable for user define repl to some filetype to haskell, ruby --- plugin/repl.vim | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/plugin/repl.vim b/plugin/repl.vim index 5aa2848..edbf26c 100644 --- a/plugin/repl.vim +++ b/plugin/repl.vim @@ -1,3 +1,14 @@ +let g:repl#default_filetype_repl = get(g:, 'repl_filetype_repl', { +\ 'haskell' : { +\ 'repl' : 'ghci', +\ 'opt' : '' +\ }, +\ 'ruby' : { +\ 'repl' : 'irb', +\ 'opt' : '--simple-prompt -r' +\ } +\}) + function! Repl() if &filetype == 'ruby' call ReplRuby() @@ -34,7 +45,11 @@ function! ReplRuby() let l:module_file = expand('%:p') endif - let l:args = 'irb --simple-prompt -r ' . l:module_file + let l:repl = exists('g:repl_filetype_repl.ruby') ? g:repl_filetype_repl.ruby['repl'] + \ : g:repl#default_filetype_repl.ruby['repl'] + let l:opt = exists('g:repl_filetype_repl.ruby') ? g:repl_filetype_repl.ruby['opt'] + \ : g:repl#default_filetype_repl.ruby['opt'] + let l:args = printf('%s %s %s', l:repl, l:opt, l:module_file) execute ':VimShellInteractive' l:args endfunction @@ -48,7 +63,11 @@ function! ReplHaskell() let l:module_file = expand('%:p') endif - let l:args = 'ghci ' . l:module_file + let l:repl = exists('g:repl_filetype_repl.haskell') ? g:repl_filetype_repl.haskell['repl'] + \ : g:repl#default_filetype_repl.haskell['repl'] + let l:opt = exists('g:repl_filetype_repl.haskell') ? g:repl_filetype_repl.haskell['opt'] + \ : g:repl#default_filetype_repl.haskell['opt'] + let l:args = printf('%s %s %s', l:repl, l:opt, l:module_file) execute ':VimShellInteractive' l:args endfunction