mirror of
https://github.com/junegunn/vim-plug.git
synced 2024-12-19 18:47:29 -07:00
Merge pull request #39 from vheon/fix-type-parameter-clarity
Replace return value of type() with call to the function
This commit is contained in:
commit
706f7e00ea
16
plug.vim
16
plug.vim
@ -71,6 +71,12 @@ let s:plug_buf = -1
|
|||||||
let s:mac_gui = has('gui_macvim') && has('gui_running')
|
let s:mac_gui = has('gui_macvim') && has('gui_running')
|
||||||
let s:is_win = has('win32') || has('win64')
|
let s:is_win = has('win32') || has('win64')
|
||||||
let s:me = expand('<sfile>:p')
|
let s:me = expand('<sfile>:p')
|
||||||
|
let s:TYPE = {
|
||||||
|
\ 'string': type(""),
|
||||||
|
\ 'list': type([]),
|
||||||
|
\ 'dict': type({}),
|
||||||
|
\ 'funcref': type(function("call"))
|
||||||
|
\ }
|
||||||
|
|
||||||
function! plug#begin(...)
|
function! plug#begin(...)
|
||||||
if a:0 > 0
|
if a:0 > 0
|
||||||
@ -114,7 +120,7 @@ function! plug#begin(...)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:to_a(v)
|
function! s:to_a(v)
|
||||||
return type(a:v) == 3 ? a:v : [a:v]
|
return type(a:v) == s:TYPE.list ? a:v : [a:v]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! plug#end()
|
function! plug#end()
|
||||||
@ -289,9 +295,9 @@ function! s:add(force, ...)
|
|||||||
let plugin = a:1
|
let plugin = a:1
|
||||||
elseif a:0 == 2
|
elseif a:0 == 2
|
||||||
let plugin = a:1
|
let plugin = a:1
|
||||||
if type(a:2) == 1
|
if type(a:2) == s:TYPE.string
|
||||||
let opts.branch = a:2
|
let opts.branch = a:2
|
||||||
elseif type(a:2) == 4
|
elseif type(a:2) == s:TYPE.dict
|
||||||
call extend(opts, a:2)
|
call extend(opts, a:2)
|
||||||
if has_key(opts, 'tag')
|
if has_key(opts, 'tag')
|
||||||
let opts.branch = remove(opts, 'tag')
|
let opts.branch = remove(opts, 'tag')
|
||||||
@ -452,10 +458,10 @@ function! s:do(pull, todo)
|
|||||||
\ !empty(s:system_chomp('git log --pretty=format:"%h" "HEAD...HEAD@{1}"')))
|
\ !empty(s:system_chomp('git log --pretty=format:"%h" "HEAD...HEAD@{1}"')))
|
||||||
call append(3, '- Post-update hook for '. name .' ... ')
|
call append(3, '- Post-update hook for '. name .' ... ')
|
||||||
let type = type(spec.do)
|
let type = type(spec.do)
|
||||||
if type == 1 " String
|
if type == s:TYPE.string
|
||||||
call system(spec.do)
|
call system(spec.do)
|
||||||
let result = v:shell_error ? ('Exit status: '.v:shell_error) : 'Done!'
|
let result = v:shell_error ? ('Exit status: '.v:shell_error) : 'Done!'
|
||||||
elseif type == 2 " Funcref
|
elseif type == s:TYPE.funcref
|
||||||
try
|
try
|
||||||
call spec.do()
|
call spec.do()
|
||||||
let result = 'Done!'
|
let result = 'Done!'
|
||||||
|
Loading…
Reference in New Issue
Block a user