From 6b9e75174e5d211ca41295667da48a859c58bb2d Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 9 Nov 2014 07:10:17 -0500 Subject: Move functions to autoload Clean up functions, move everything into autoload/, move code around a little bit. --- plugin/auditory.vim | 196 +--------------------------------------------------- 1 file changed, 2 insertions(+), 194 deletions(-) (limited to 'plugin') diff --git a/plugin/auditory.vim b/plugin/auditory.vim index e15f42e..87585a3 100644 --- a/plugin/auditory.vim +++ b/plugin/auditory.vim @@ -1,202 +1,10 @@ -" Get the script path so we can resolve the audio file paths -let s:script_path = resolve(expand(':p:h')) . '/..' - - -" Pid -" === - -" Get most recent mplayer pid -function! s:GetPid() - return system("ps | grep mplayer | head -n1 | awk '{printf $1}'") -endfunction - -" Run system kill -function! s:KillPid(pid) - return system("kill " . a:pid) -endfunction - -" Play audio -function! auditory#Play(file) - call system("mplayer " . s:script_path . a:file . " &") -endfunction - -" Insert mode functions -function! s:PlayInsertEnter() - call auditory#Play("/private/test-track.mp3") - let s:insert_mode_pid = s:GetPid() -endfunction - -function! s:PlayInsertLeave() - call s:KillPid(s:insert_mode_pid) -endfunction - -function! s:PlayScale() - let play_scale_previous_note = -1 - let note = -1 - let scale = [ - \ '1_C#.wav', - \ '2_D#.wav', - \ '3_E#.wav', - \ '4_F#.wav', - \ '5_G#.wav', - \ '6_A#.wav', - \ '7_B#.wav' - \ ] - - while play_scale_previous_note ==# note - let note = system("echo $RANDOM % " . len(scale) . " | bc") - endwhile - - let play_scale_previous_note = note - - call auditory#Play('/Resources/Scale_C#/' . scale[note]) -endfunction - - -let s:galaxy_far_far_away_index = 0 -function! s:GalaxyFarFarAway() - let cantina = [ - \ 'Cantina_1.1.wav', - \ 'Cantina_1.2.wav', - \ 'Cantina_1.3.wav', - \ 'Cantina_1.4.wav', - \ 'Cantina_2.1.wav', - \ 'Cantina_2.2.wav', - \ 'Cantina_2.3.wav', - \ 'Cantina_2.4.wav', - \ 'Cantina_3.1.wav', - \ 'Cantina_3.2.wav', - \ 'Cantina_3.3.wav', - \ 'Cantina_3.4.wav', - \ 'Cantina_4.1.wav', - \ 'Cantina_4.2.wav', - \ 'Cantina_4.3.wav', - \ 'Cantina_4.4.wav', - \ 'Cantina_5.1.wav', - \ 'Cantina_5.2.wav', - \ 'Cantina_5.3.wav', - \ 'Cantina_5.4.wav', - \ 'Cantina_6.1.wav', - \ 'Cantina_6.2.wav', - \ 'Cantina_6.3.wav', - \ 'Cantina_6.4.wav', - \ 'Cantina_7.1.wav', - \ 'Cantina_7.2.wav', - \ 'Cantina_7.3.wav', - \ 'Cantina_7.4.wav', - \ 'Cantina_8.1.wav', - \ 'Cantina_8.2.wav', - \ 'Cantina_8.3.wav', - \ 'Cantina_8.4.wav' - \ ] - - call auditory#Play('/Resources/Cantina/' . cantina[s:galaxy_far_far_away_index]) - - let s:galaxy_far_far_away_index += 1 - - if s:galaxy_far_far_away_index >= len(cantina) - let s:galaxy_far_far_away_index = 0 - endif -endfunction - - -" Normal mode -function! s:NormalModeMappings() - nnoremap h :call auditory#Play('/Resources/Normal_Mode/Left.wav') \| exec 'normal!' v:count1 . 'h' - nnoremap j :call auditory#Play('/Resources/Normal_Mode/Down.wav') \| exec 'normal!' v:count1 . 'j' - nnoremap k :call auditory#Play('/Resources/Normal_Mode/Up.wav') \| exec 'normal!' v:count1 . 'k' - nnoremap l :call auditory#Play('/Resources/Normal_Mode/Right.wav') \| exec 'normal!' v:count1 . 'l' - - nnoremap gj :call auditory#Play('/Resources/Normal_Mode/Down.wav') \| exec 'normal!' v:count1 . 'gj' - nnoremap gk :call auditory#Play('/Resources/Normal_Mode/Up.wav') \| exec 'normal!' v:count1 . 'gk' - - " nnoremap :call auditory#Play('/Resources/Normal_Mode/Down.wav') \| exec 'normal!' v:count1 . '' - " nnoremap :call auditory#Play('/Resources/Normal_Mode/Up.wav') \| exec 'normal!' v:count1 . '' - - nnoremap 0 :call auditory#Play('/Resources/Normal_Mode/Left.wav') \| exec 'normal!' v:count1 . '0' - nnoremap ^ :call auditory#Play('/Resources/Normal_Mode/Left.wav') \| exec 'normal!' v:count1 . '^' - nnoremap _ :call auditory#Play('/Resources/Normal_Mode/Left.wav') \| exec 'normal!' v:count1 . '_' - nnoremap $ :call auditory#Play('/Resources/Normal_Mode/Right.wav') \| exec 'normal!' v:count1 . '$' - nnoremap g_ :call auditory#Play('/Resources/Normal_Mode/Right.wav') \| exec 'normal!' v:count1 . 'g_' - nnoremap % :call auditory#Play('/Resources/Normal_Mode/Jump.wav')% - - nnoremap b :call auditory#Play('/Resources/Normal_Mode/Left.wav') \| exec 'normal!' v:count1 . 'b' - nnoremap w :call auditory#Play('/Resources/Normal_Mode/Right.wav') \| exec 'normal!' v:count1 . 'w' - nnoremap e :call auditory#Play('/Resources/Normal_Mode/Right.wav') \| exec 'normal!' v:count1 . 'e' - nnoremap B :call auditory#Play('/Resources/Normal_Mode/Left.wav') \| exec 'normal!' v:count1 . 'B' - nnoremap W :call auditory#Play('/Resources/Normal_Mode/Right.wav') \| exec 'normal!' v:count1 . 'W' - nnoremap E :call auditory#Play('/Resources/Normal_Mode/Right.wav') \| exec 'normal!' v:count1 . 'E' - - nnoremap p :call auditory#Play('/Resources/Normal_Mode/Paste.wav') \| exec 'normal!' v:count1 . 'p' - nnoremap P :call auditory#Play('/Resources/Normal_Mode/Paste.wav') \| exec 'normal!' v:count1 . 'P' - - nnoremap / :call auditory#Play('/Resources/Normal_Mode/Search.wav')/ - nnoremap n :call auditory#Play('/Resources/Normal_Mode/Search.wav')n - nnoremap N :call auditory#Play('/Resources/Normal_Mode/Search.wav')N - nnoremap # :call auditory#Play('/Resources/Normal_Mode/Search.wav')# - nnoremap * :call auditory#Play('/Resources/Normal_Mode/Search.wav')* - - nnoremap zt :call auditory#Play('/Resources/Normal_Mode/Jump.wav')zt - nnoremap z. :call auditory#Play('/Resources/Normal_Mode/Jump.wav')z. - nnoremap zz :call auditory#Play('/Resources/Normal_Mode/Jump.wav')zz - nnoremap zb :call auditory#Play('/Resources/Normal_Mode/Jump.wav')zb - " nnoremap :call auditory#Play('/Resources/Normal_Mode/Jump.wav') \| exec 'normal!' v:count1 . '' - " nnoremap :call auditory#Play('/Resources/Normal_Mode/Jump.wav') \| exec 'normal!' v:count1 . '' - " nnoremap :call auditory#Play('/Resources/Normal_Mode/Jump.wav') \| exec 'normal!' v:count1 . 'cr> - " nnoremap :call auditory#Play('/Resources/Normal_Mode/Jump.wav') \| exec 'normal!' v:count1 . '' - - nnoremap ( :call auditory#Play('/Resources/Normal_Mode/Jump.wav') \| exec 'normal!' v:count1 . '(' - nnoremap ) :call auditory#Play('/Resources/Normal_Mode/Jump.wav') \| exec 'normal!' v:count1 . ')' - nnoremap { :call auditory#Play('/Resources/Normal_Mode/Jump.wav') \| exec 'normal!' v:count1 . '{' - nnoremap } :call auditory#Play('/Resources/Normal_Mode/Jump.wav') \| exec 'normal!' v:count1 . '}' - - nnoremap :call auditory#Play('/Resources/Normal_Mode/Jump.wav') \| exec 'normal!' v:count1 . '' - nnoremap :call auditory#Play('/Resources/Normal_Mode/Jump.wav') \| exec 'normal!' v:count1 . '' - - nnoremap gg :call auditory#Play('/Resources/Normal_Mode/Jump.wav') \| exec 'normal!' v:count1 . 'gg' - nnoremap G :call auditory#Play('/Resources/Normal_Mode/Jump.wav') \| exec 'normal!' v:count . 'G' - - nnoremap x :call auditory#Play('/Resources/Normal_Mode/Delete.wav') \| exec 'normal!' v:count1 . 'x' - vnoremap x :call auditory#Play('/Resources/Normal_Mode/Delete.wav') \| exec 'normal!' v:count1 . 'x' - " nnoremap d :call auditory#Play('/Resources/Normal_Mode/Delete.wav') \| exec 'normal!' v:count1 . 'd' - " nnoremap d :set opfunc=d \| call auditory#Play('/Resources/Normal_Mode/Delete.wav') \| exec 'normal!' v:count1 . @g - - " inoremap :call auditory#Play('/Resources/auto_complete.wav')a - " inoremap :call auditory#Play('/Resources/auto_complete.wav')a -endfunction - -call s:NormalModeMappings() - - - -let s:galaxy_far_far_away = 0 -function! auditory#ToggleGalaxyFarFarAway() - if s:galaxy_far_far_away - augroup auditory#insert_mode - autocmd! - autocmd CursorMovedI * call PlayScale() - augroup END - let s:galaxy_far_far_away = 0 - else - augroup auditory#insert_mode - autocmd! - autocmd CursorMovedI * call GalaxyFarFarAway() - augroup END - let s:galaxy_far_far_away = 1 - endif -endfunction - - - augroup auditory#insert_mode autocmd! - " autocmd InsertEnter * call s:PlayInsertEnter() - " autocmd InsertLeave * call s:PlayInsertLeave() - autocmd CursorMovedI * call PlayScale() + autocmd CursorMovedI * call auditory#PlayScale() augroup END command! AuditoryToggleGalaxyFarFarAway call auditory#ToggleGalaxyFarFarAway() -nnoremap so :source % +call auditory#NormalModeMappings() -- cgit v1.2.3