From e573b3020c032400eed60b649a2cbf55266e6bb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Thu, 30 Jun 2016 16:03:25 +0200 Subject: Add current configurations from old repository --- vim/bundle/tlib_vim/autoload/tlib/dictionary.vim | 45 ++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 vim/bundle/tlib_vim/autoload/tlib/dictionary.vim (limited to 'vim/bundle/tlib_vim/autoload/tlib/dictionary.vim') diff --git a/vim/bundle/tlib_vim/autoload/tlib/dictionary.vim b/vim/bundle/tlib_vim/autoload/tlib/dictionary.vim new file mode 100644 index 0000000..a778519 --- /dev/null +++ b/vim/bundle/tlib_vim/autoload/tlib/dictionary.vim @@ -0,0 +1,45 @@ +" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim]) +" @Website: https://github.com/tomtom +" @License: GPL (see http://www.gnu.org/licenses/gpl.txt) +" @Last Change: 2016-04-06 +" @Revision: 22 + + +" :display: tlib#dictionary#Rev(dict, ?opts = {}) abort "{{{3 +function! tlib#dictionary#Rev(dict, ...) abort "{{{3 + let opts = a:0 >= 1 ? a:1 : {} + Tlibtype a:dict, 'dict', opts, 'dict' + let rev = {} + let use_string = get(opts, 'use_string', 0) + let use_eval = get(opts, 'use_eval', 0) + let values_as_list = get(opts, 'values_as_list', 0) + for [m, f] in items(a:dict) + if use_string + let k = string(f) + else + let k = type(f) == 1 ? f : string(f) + if k ==# '' + let k = get(opts, 'empty', '') + if empty(k) + continue + endif + endif + endif + if use_eval + let v = eval(m) + else + let v = m + endif + if values_as_list + if has_key(rev, k) + call add(rev[k], v) + else + let rev[k] = [v] + endif + else + let rev[k] = v + endif + endfor + return rev +endf + -- cgit v1.2.3