Skip to content

Commit

Permalink
Add g:which_key_ignore_outside_mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
rene-descartes2021 committed Jun 30, 2022
1 parent 654dfc1 commit 4d64b22
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ nnoremap <leader>_b :echom '_b'<CR>
let g:which_key_map['_'] = { 'name': 'which_key_ignore' }
```

If you want to hide all mappings outside of the elements of the description dictionary, use: `let g:which_key_ignore_outside_mappings = 1`.

#### Example

You can configure a Dict for each prefix so that the display is more readable.
Expand Down
4 changes: 3 additions & 1 deletion autoload/which_key.vim
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ function! s:merge(target, native) " {{{
endif
endfor

call extend(target, native, 'keep')
if !g:which_key_ignore_outside_mappings
call extend(target, native, 'keep')
endif
endfunction

function! s:echo_prompt() abort
Expand Down
6 changes: 5 additions & 1 deletion doc/vim-which-key.txt
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,13 @@ Default: `1`

Ignore the invalid key and let you continue to input the valid ones. Otherwise
an error message will be popuped and abort the guide buffer.
*g:which_key_ignore_outside_mappings*
Type: |Number|
Default: `0`

Hides all mappings outside of the elements of the description dictionary.
*'which_key_ignore'*
If you wish to hide a mapping from the menu set its description to
If you wish to hide a specific mapping from the menu set its description to
`'which_key_ignore'`:
>
nnoremap <leader>1 :1wincmd w<CR>
Expand Down
1 change: 1 addition & 0 deletions plugin/which_key.vim
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ let g:which_key_sort_horizontal = get(g:, 'which_key_sort_horizontal', 0)
let g:which_key_run_map_on_popup = get(g:, 'which_key_run_map_on_popup', 1)
let g:which_key_align_by_seperator = get(g:, 'which_key_align_by_seperator', 1)
let g:which_key_ignore_invalid_key = get(g:, 'which_key_ignore_invalid_key', 1)
let g:which_key_ignore_outside_mappings = get(g:, 'which_key_ignore_outside_mappings', 0)
let g:which_key_fallback_to_native_key = get(g:, 'which_key_fallback_to_native_key', 0)
let g:which_key_default_group_name = get(g:, 'which_key_default_group_name', '+prefix')
let g:which_key_use_floating_win = (exists('*nvim_open_win') || exists('*popup_create')) && get(g:, 'which_key_use_floating_win', 1)
Expand Down

0 comments on commit 4d64b22

Please sign in to comment.