Clone wiki

VimLabo / RDict

function! RDict(dictName)
    if !exists(a:dictName)
        echo a:dictName
        return
    endif

    if input('assign? (' . a:dictName . ')  Y/N' . " : ") =~? '\v^y(es)?$'
        let l:val = string(input(string(a:dictName) . 'is ', string(eval(a:dictName))))
        if l:val != ''
            execute 'let ' . a:dictName . ' = ' eval(l:val)
        endif
        return
    endif

    if type(eval(a:dictName)) !=? type({})
        return
    endif

    let s:keys = keys(eval(a:dictName))
    return RDict(a:dictName . '[' . string(input(a:dictName . ' key ', '', 'customlist,RDictGetDictKey')) . ']')
endfunction


function! RDictGetDictKey(a, l, p)
    let l:keys = filter(s:keys, 'v:val =~? ''' .  a:a . '''')
    return l:keys
endfunction

command! RDictTest :call RDict('g:quickrun_config')

Updated