1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-03-12 17:55:41 +08:00
Wang Shidong 3ccd4e4680
update file head (#1407)
* update file head

Update file head

* Update file head

* Update file head
2018-02-19 22:07:04 +08:00

40 lines
1.1 KiB
VimL

"=============================================================================
" frequency.vim --- key frequency plugin
" Copyright (c) 2016-2017 Wang Shidong & Contributors
" Author: Wang Shidong < wsdjeg at 163.com >
" URL: https://spacevim.org
" License: GPLv3
"=============================================================================
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