From 340cf5a64b97cc9f123a85953c7f5b9bf93d2a9e Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 19 Jul 2015 12:28:11 -0400 Subject: 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. --- autoload/auditory.vim | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'autoload') 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 -- cgit v1.2.3