From 9779b2cee0ab633cfdc7c71f3544aa9741957b7d Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 18 Jul 2015 21:01:03 -0400 Subject: auditory.vim: Assign mappings with AssignNormalModeMappings() Assign our normal mode mappings with our new function that uses the mapping dictionary. --- plugin/auditory.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugin') diff --git a/plugin/auditory.vim b/plugin/auditory.vim index 821c5ba..ba46fa2 100644 --- a/plugin/auditory.vim +++ b/plugin/auditory.vim @@ -20,4 +20,4 @@ augroup END command! AuditoryToggleGalaxyFarFarAway call auditory#ToggleGalaxyFarFarAway() -call auditory#NormalModeMappings() +call auditory#AssignNormalModeMappings() -- cgit v1.2.3 From 98b259d4065ef5b986d5d3cda953518061a6117f Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 19 Jul 2015 11:42:47 -0400 Subject: auditory.vim: `AssignNormalModeMappings` -> `AssignMappings` Rename the function because we're not only assigning normal mode mappings here, we're also assigning visual mode mappings. And we might be assigning mappings for other modes here too in the future, so this name doesn't make sense. I had originally called it this to distinguish it from the insert mode set defined in plugin/auditory.vim with the `CursorMovedI` autocommand, but I think this should be more clear about what it's doing. Edit: Also modify the comment above this section for similar reasons. --- plugin/auditory.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugin') diff --git a/plugin/auditory.vim b/plugin/auditory.vim index ba46fa2..87bfd71 100644 --- a/plugin/auditory.vim +++ b/plugin/auditory.vim @@ -20,4 +20,4 @@ augroup END command! AuditoryToggleGalaxyFarFarAway call auditory#ToggleGalaxyFarFarAway() -call auditory#AssignNormalModeMappings() +call auditory#AssignMappings() -- cgit v1.2.3 From a4cf047b6cc8b9f09c4aa56dbf230e66bf7497b5 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Tue, 28 Jul 2015 00:09:37 -0400 Subject: plugin/auditory.vim: Add `:AuditoryOff` command New command that turns the plugin off by removing its mappings. --- plugin/auditory.vim | 1 + 1 file changed, 1 insertion(+) (limited to 'plugin') diff --git a/plugin/auditory.vim b/plugin/auditory.vim index 87bfd71..21082f0 100644 --- a/plugin/auditory.vim +++ b/plugin/auditory.vim @@ -18,6 +18,7 @@ augroup END command! AuditoryToggleGalaxyFarFarAway call auditory#ToggleGalaxyFarFarAway() +command! AuditoryOff call auditory#Unmap() call auditory#AssignMappings() -- cgit v1.2.3 From a612f8fb835df92648401606dec6c2d07fa3ae4b Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 16 Aug 2015 02:19:58 -0400 Subject: Unmap insert mode sounds from `auditory#Unmap()` * Move the insert mode autocommand definition into a new function that turns on insert mode sounds * Create a function to turn off insert mode sounds * Call these from our normal `AssignMappings` and `Unmap` functions so we can turn all our sounds on and off in one fell swoop --- plugin/auditory.vim | 6 ------ 1 file changed, 6 deletions(-) (limited to 'plugin') diff --git a/plugin/auditory.vim b/plugin/auditory.vim index 21082f0..e8ceeba 100644 --- a/plugin/auditory.vim +++ b/plugin/auditory.vim @@ -11,12 +11,6 @@ if !executable('mplayer') endif -augroup auditory#insert_mode - autocmd! - autocmd CursorMovedI * call auditory#PlayScale() -augroup END - - command! AuditoryToggleGalaxyFarFarAway call auditory#ToggleGalaxyFarFarAway() command! AuditoryOff call auditory#Unmap() -- cgit v1.2.3 From f3444f5dcfa269eee62b8daf552b3ed29a43aa04 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 16 Aug 2015 02:26:56 -0400 Subject: plugin/auditory.vim: Add `:AuditoryOn` command Create a new command to match `:AuditoryOff` that turns on mappings and sounds. We'll need this because I'm going to make the plugin not enable sounds by default. That will be controlled by a global variable. You'll be able to turn the sounds on and off as you wish. --- plugin/auditory.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'plugin') diff --git a/plugin/auditory.vim b/plugin/auditory.vim index e8ceeba..e0a764a 100644 --- a/plugin/auditory.vim +++ b/plugin/auditory.vim @@ -11,8 +11,9 @@ if !executable('mplayer') endif -command! AuditoryToggleGalaxyFarFarAway call auditory#ToggleGalaxyFarFarAway() +command! AuditoryOn call auditory#AssignMappings() command! AuditoryOff call auditory#Unmap() +command! AuditoryToggleGalaxyFarFarAway call auditory#ToggleGalaxyFarFarAway() call auditory#AssignMappings() -- cgit v1.2.3 From 957cc40ba08d66d9b39edda074662677d3d6f21a Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 16 Aug 2015 02:34:36 -0400 Subject: plugin/auditory.vim: Check for `g:auditory_on` Don't heedlessly turn on sounds when the plugin is loaded. Instead, give users a choice of whether or not sounds should be loaded when starting Vim with a configuration variable that can be set in a user vimrc. By default sounds are now off. --- plugin/auditory.vim | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'plugin') diff --git a/plugin/auditory.vim b/plugin/auditory.vim index e0a764a..593617e 100644 --- a/plugin/auditory.vim +++ b/plugin/auditory.vim @@ -11,9 +11,16 @@ if !executable('mplayer') endif +if !exists('g:auditory_on') + let g:auditory_on = 0 +endif + + command! AuditoryOn call auditory#AssignMappings() command! AuditoryOff call auditory#Unmap() command! AuditoryToggleGalaxyFarFarAway call auditory#ToggleGalaxyFarFarAway() -call auditory#AssignMappings() +if g:auditory_on ==# 1 + call auditory#AssignMappings() +endif -- cgit v1.2.3 From da0a9cf9fba990b5d39041b43b7257599fd4c5a4 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 16 Aug 2015 02:39:22 -0400 Subject: plugin/auditory.vim: Condense `g:auditory_on` check Realised that I don't need to explicitly check for 1, I can check against true or false. Get rid of the explicit check to make this more concise. --- plugin/auditory.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugin') diff --git a/plugin/auditory.vim b/plugin/auditory.vim index 593617e..39ae283 100644 --- a/plugin/auditory.vim +++ b/plugin/auditory.vim @@ -21,6 +21,6 @@ command! AuditoryOff call auditory#Unmap() command! AuditoryToggleGalaxyFarFarAway call auditory#ToggleGalaxyFarFarAway() -if g:auditory_on ==# 1 +if g:auditory_on call auditory#AssignMappings() endif -- cgit v1.2.3 From 8a0fd42b1df21aa9bd1c9d6f8b169d060ea8db6e Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 16 Aug 2015 02:43:09 -0400 Subject: Add function and command to toggle mappings * Create `auditory#ToggleMappings()` that turns sounds on if they're off and off if they're on * Create an `:AuditoryToggle` command that runs the toggle function in a more user-friendly callable way With a toggle command, turning Auditory on or off can be as simple as hitting 1 custom mapping. With our previous `AuditoryOn` and `AuditoryOff`, you would have to use 2 mappings: 1 for on and another for off. --- plugin/auditory.vim | 1 + 1 file changed, 1 insertion(+) (limited to 'plugin') diff --git a/plugin/auditory.vim b/plugin/auditory.vim index 39ae283..378fd39 100644 --- a/plugin/auditory.vim +++ b/plugin/auditory.vim @@ -18,6 +18,7 @@ endif command! AuditoryOn call auditory#AssignMappings() command! AuditoryOff call auditory#Unmap() +command! AuditoryToggle call auditory#ToggleMappings() command! AuditoryToggleGalaxyFarFarAway call auditory#ToggleGalaxyFarFarAway() -- cgit v1.2.3 From 71ec214cdb8814ecb71c837bf947583fda54d37e Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 16 Aug 2015 14:45:33 -0400 Subject: Create a setting for Galaxy Far Far Away sounds Adding a configuration variable for these sounds allows them to be turned on by default without having to `:AuditoryToggleGalaxyFarFarAway`, so if you prefer these sounds you can enable them at the outset. --- plugin/auditory.vim | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'plugin') diff --git a/plugin/auditory.vim b/plugin/auditory.vim index 378fd39..d740561 100644 --- a/plugin/auditory.vim +++ b/plugin/auditory.vim @@ -15,6 +15,10 @@ if !exists('g:auditory_on') let g:auditory_on = 0 endif +if !exists('g:auditory_galaxy_far_far_away') + let g:auditory_galaxy_far_far_away = 0 +endif + command! AuditoryOn call auditory#AssignMappings() command! AuditoryOff call auditory#Unmap() @@ -25,3 +29,8 @@ command! AuditoryToggleGalaxyFarFarAway call auditory#ToggleGalaxyFarFarAway() if g:auditory_on call auditory#AssignMappings() endif + +if g:auditory_galaxy_far_far_away + let g:auditory_galaxy_far_far_away = 0 + call auditory#ToggleGalaxyFarFarAway() +endif -- cgit v1.2.3 From 1c9fe852b40d4e7a883bcdc71c91abdd023514bb Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 16 Aug 2015 14:50:35 -0400 Subject: Don't turn on Galaxy Far Far away when not `g:auditory_on` My change from 71ec214cdb8814ecb71c837bf947583fda54d37e caused Galaxy Far Far Away sounds to be turned on any time you had `g:auditory_galaxy_far_far_away` turned on, regardless of whether `g:auditory_on` was also turned on. Fix this because we never want sounds to play when `g:auditory_on` is off. We now rely on `auditory#AssignInsertMappings()` to know whether to use Galaxy Far Far Away or default insert mode sounds. Need to toggle `g:auditory_galaxy_far_far_away` in that function because we're calling the toggle function so we need to set it to the opposite of what we want. In the future if we add more insert mode sounds we'll have to change this structure around but it should work for now. --- plugin/auditory.vim | 5 ----- 1 file changed, 5 deletions(-) (limited to 'plugin') diff --git a/plugin/auditory.vim b/plugin/auditory.vim index d740561..411a812 100644 --- a/plugin/auditory.vim +++ b/plugin/auditory.vim @@ -29,8 +29,3 @@ command! AuditoryToggleGalaxyFarFarAway call auditory#ToggleGalaxyFarFarAway() if g:auditory_on call auditory#AssignMappings() endif - -if g:auditory_galaxy_far_far_away - let g:auditory_galaxy_far_far_away = 0 - call auditory#ToggleGalaxyFarFarAway() -endif -- cgit v1.2.3