Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix maktaba#value#TypeName to handle new/all current types #213

Merged
merged 3 commits into from
May 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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