diff options
| author | Teddy Wing | 2015-07-19 12:28:11 -0400 |
|---|---|---|
| committer | Teddy Wing | 2015-07-19 12:28:11 -0400 |
| commit | 340cf5a64b97cc9f123a85953c7f5b9bf93d2a9e (patch) | |
| tree | 95d88d4252f8ecd79c3b69aa34515fa5159bdbfa /autoload | |
| parent | 98b259d4065ef5b986d5d3cda953518061a6117f (diff) | |
| download | auditory.vim-340cf5a64b97cc9f123a85953c7f5b9bf93d2a9e.tar.bz2 | |
autoload/auditory.vim: Add function to store user mappings
Get any mappings users have defined for the keys/commands that we use
for playing audio and store them in our `mappings` dictionary. This will
allow us to be friendly and have the keys do what users have defined
them to do instead of using the stock Vim actions for everything.
Storing these mappings will also allow us to easily restore user
mappings when we make a way to turn the plugin's sounds off by unmapping
our custom sound maps.
Diffstat (limited to 'autoload')
| -rw-r--r-- | autoload/auditory.vim | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/autoload/auditory.vim b/autoload/auditory.vim index 915c561..0476631 100644 --- a/autoload/auditory.vim +++ b/autoload/auditory.vim @@ -463,3 +463,18 @@ function! auditory#AssignMappings() \ l:pipe . value.map_to endfor endfunction + + +" If users have a custom mapping for any of the commands we need, store the +" mapping so we can map to it after playing audio and so we can restore the +" user's mappings when the plugin is toggled off. +function! auditory#StoreUserMappings() + for [key, value] in items(s:mappings) + let l:map_from = has_key(value, 'map_from') ? value.map_from : key + let l:user_mapping = maparg(l:map_from) + + if l:user_mapping + let value.user_mapping = l:user_mapping + endif + endfor +endfunction |
