Refactor code
Use get()
This commit is contained in:
parent
dd5619856f
commit
5e074a331c
@ -5,6 +5,7 @@ set cpo&vim
|
|||||||
"TODO: Branch python2 and python3
|
"TODO: Branch python2 and python3
|
||||||
"TODO: DRY
|
"TODO: DRY
|
||||||
|
|
||||||
|
|
||||||
function! s:echo_error(msg) abort
|
function! s:echo_error(msg) abort
|
||||||
echohl Error
|
echohl Error
|
||||||
echomsg a:msg
|
echomsg a:msg
|
||||||
@ -48,10 +49,8 @@ function! repl#start_ruby() abort
|
|||||||
let l:module_file = expand('%:p')
|
let l:module_file = expand('%:p')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let l:repl = exists('g:repl_filetype_repl.ruby') ? g:repl_filetype_repl.ruby['repl']
|
let l:repl = get(g:, 'repl_filetype_repl.ruby.repl', g:repl#default_filetype_repl.ruby['repl'])
|
||||||
\ : g:repl#default_filetype_repl.ruby['repl']
|
let l:opt = get(g:, 'repl_filetype_repl.ruby.opt', g:repl#default_filetype_repl.ruby['opt'])
|
||||||
let l:opt = exists('g:repl_filetype_repl.ruby') ? g:repl_filetype_repl.ruby['opt']
|
|
||||||
\ : g:repl#default_filetype_repl.ruby['opt']
|
|
||||||
if !executable(l:repl)
|
if !executable(l:repl)
|
||||||
call s:echo_error(printf("You don't have repl: '%s'", l:repl))
|
call s:echo_error(printf("You don't have repl: '%s'", l:repl))
|
||||||
return
|
return
|
||||||
@ -70,10 +69,8 @@ function! repl#start_haskell() abort
|
|||||||
let l:module_file = expand('%:p')
|
let l:module_file = expand('%:p')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let l:repl = exists('g:repl_filetype_repl.haskell') ? g:repl_filetype_repl.haskell['repl']
|
let l:repl = get(g:, 'repl_filetype_repl.haskell.repl', g:repl#default_filetype_repl.haskell['repl'])
|
||||||
\ : g:repl#default_filetype_repl.haskell['repl']
|
let l:opt = get(g:, 'repl_filetype_repl.haskell.opt', g:repl#default_filetype_repl.haskell['opt'])
|
||||||
let l:opt = exists('g:repl_filetype_repl.haskell') ? g:repl_filetype_repl.haskell['opt']
|
|
||||||
\ : g:repl#default_filetype_repl.haskell['opt']
|
|
||||||
if !executable(l:repl)
|
if !executable(l:repl)
|
||||||
call s:echo_error(printf("You don't have repl: '%s'", l:repl))
|
call s:echo_error(printf("You don't have repl: '%s'", l:repl))
|
||||||
return
|
return
|
||||||
@ -92,10 +89,8 @@ function! repl#start_python() abort
|
|||||||
let l:module_file = expand('%:p')
|
let l:module_file = expand('%:p')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let l:repl = exists('g:repl_filetype_repl.python') ? g:repl_filetype_repl.python['repl']
|
let l:repl = get(g:, 'repl_filetype_repl.python.repl', g:repl#default_filetype_repl.python['repl'])
|
||||||
\ : g:repl#default_filetype_repl.python['repl']
|
let l:opt = get(g:, 'repl_filetype_repl.python.opt', g:repl#default_filetype_repl.python['opt'])
|
||||||
let l:opt = exists('g:repl_filetype_repl.python') ? g:repl_filetype_repl.python['opt']
|
|
||||||
\ : g:repl#default_filetype_repl.python['opt']
|
|
||||||
if !executable(l:repl)
|
if !executable(l:repl)
|
||||||
call s:echo_error(printf("You don't have repl: '%s'", l:repl))
|
call s:echo_error(printf("You don't have repl: '%s'", l:repl))
|
||||||
return
|
return
|
||||||
@ -132,10 +127,8 @@ function! repl#start_erlang() abort
|
|||||||
cd %:p:h
|
cd %:p:h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let l:repl = exists('g:repl_filetype_repl.erlang') ? g:repl_filetype_repl.erlang['repl']
|
let l:repl = get(g:, 'repl_filetype_repl.erlang.repl', g:repl#default_filetype_repl.erlang['repl'])
|
||||||
\ : g:repl#default_filetype_repl.erlang['repl']
|
let l:opt = get(g:, 'repl_filetype_repl.erlang.opt', g:repl#default_filetype_repl.erlang['opt'])
|
||||||
let l:opt = exists('g:repl_filetype_repl.erlang') ? g:repl_filetype_repl.erlang['opt']
|
|
||||||
\ : g:repl#default_filetype_repl.erlang['opt']
|
|
||||||
if !executable(l:repl)
|
if !executable(l:repl)
|
||||||
call s:echo_error(printf("You don't have repl: '%s'", l:repl))
|
call s:echo_error(printf("You don't have repl: '%s'", l:repl))
|
||||||
return
|
return
|
||||||
|
Reference in New Issue
Block a user