Skip to content

Commit

Permalink
Add ability to hide shortcuts
Browse files Browse the repository at this point in the history
Shortcuts can be hidden by setting thir description to "leader_ignore", i.e. let g:lmap.w = ['w', 'leader_ignore']. Shortcut can still be executed when in leader menu.
  • Loading branch information
spinks committed Aug 31, 2018
1 parent 6ac8c66 commit 40af6b7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion autoload/leaderGuide.vim
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@ let s:displaynames = {'<C-I>': '<Tab>',
function! s:calc_layout() " {{{
let ret = {}
let smap = filter(copy(s:lmap), 'v:key !=# "name"')
for key in keys(smap)
if type(smap[key]) == type([]) && smap[key][1] == "leader_ignore"
unlet smap[key]
endif
endfor
let ret.n_items = len(smap)
let length = values(map(smap,
\ 'strdisplaywidth("[".v:key."]".'.
Expand Down Expand Up @@ -245,7 +250,11 @@ function! s:create_string(layout) " {{{
let col = 0
let smap = sort(filter(keys(s:lmap), 'v:val !=# "name"'),'1')
for k in smap
silent execute "cnoremap <nowait> <buffer> ".substitute(k, "|", "<Bar>", ""). " " . s:escape_keys(k) ."<CR>"
let desc = type(s:lmap[k]) == type({}) ? s:lmap[k].name : s:lmap[k][1]
if desc == "leader_ignore"
continue
endif
let displaystring = "[".s:show_displayname(k)."] ".desc
let crow = get(rows, row, [])
if empty(crow)
Expand Down Expand Up @@ -274,7 +283,6 @@ function! s:create_string(layout) " {{{
let col += 1
endif
endif
silent execute "cnoremap <nowait> <buffer> ".substitute(k, "|", "<Bar>", ""). " " . s:escape_keys(k) ."<CR>"
endfor
let r = []
let mlen = 0
Expand Down

0 comments on commit 40af6b7

Please sign in to comment.