mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-29 06:12:39 +08:00
32 lines
733 B
VimL
32 lines
733 B
VimL
let s:data = {}
|
|
|
|
function! SpaceVim#mapping#frequency#update(key, rhs) abort
|
|
if has_key(s:data, a:key)
|
|
let s:data[a:key] += 1
|
|
else
|
|
let s:data[a:key] = 1
|
|
endif
|
|
return a:rhs
|
|
endfunction
|
|
|
|
function! SpaceVim#mapping#frequency#view(keys) abort
|
|
if type(a:keys) == 1
|
|
echo 'The frequency of ' . a:keys . ' is ' . s:get(a:keys)
|
|
elseif type(a:keys) == 3
|
|
for key in a:keys
|
|
call SpaceVim#mapping#frequency#view(key)
|
|
endfor
|
|
endif
|
|
endfunction
|
|
function! SpaceVim#mapping#frequency#viewall() abort
|
|
echo string(s:data)
|
|
endfunction
|
|
|
|
function! s:get(key) abort
|
|
if has_key(s:data, a:key)
|
|
return s:data[a:key]
|
|
else
|
|
return 0
|
|
endif
|
|
endfunction
|