Skip to content

Commit

Permalink
Fix maktaba#value#TypeName to handle new/all current types (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed authored and dbarnett committed May 7, 2018
1 parent 77a4dce commit ffdb1a5
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions autoload/maktaba/value.vim
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ endfunction
""
" Whether {value} is in {list}.
" @throws BadValue if {list} is not a list.
function! maktaba#value#IsIn(Value, list)
function! maktaba#value#IsIn(Value, list) abort
return index(maktaba#ensure#IsList(a:list), a:Value) >= 0
endfunction

Expand Down Expand Up @@ -101,23 +101,38 @@ endfunction

""
" Returns the type of {value} as a string.
" One of "number", "string", "funcref", "list", "dictionary", or "float".
" One of "number", "string", "funcref", "list", "dictionary", "float",
" "boolean", "null", "none", "job", or "channel".
" See also |type()|.
function! maktaba#value#TypeName(Value) abort
let l:type = type(a:Value)
if l:type == 0
return "number"
return 'number'
elseif l:type == 1
return "string"
return 'string'
elseif l:type == 2
return "funcref"
return 'funcref'
elseif l:type == 3
return "list"
return 'list'
elseif l:type == 4
return "dictionary"
return 'dictionary'
elseif l:type == 5
return "float"
return 'float'
elseif l:type == 6
return 'boolean'
elseif l:type == 7
" None (v:null or v:none) in Vim.
" Null (v:null) in Neovim.
if exists('v:none') && a:Value is v:none
return 'none'
endif
return 'null'
elseif l:type == 8
return 'job'
elseif l:type == 9
return 'channel'
endif
return printf('unknown type (%d)', l:type)
endfunction


Expand Down

0 comments on commit ffdb1a5

Please sign in to comment.