"for scvim (supercollider vim)

"this indicates the -d varaible [rundir] for running sclang in
"default /tmp
"let $SCLANG_RUNDIR = "/home/user/scwork"

"set this to 0 if you don't want to kill the terminal with sclangpipe running
"in it when you exit vim
let g:sclangKillOnExit = 1

"this indicates the terminal emulator command you will use to launch
"sclangpipe_app
let g:sclangTerm = ""     "Leave it blank like this for the autodetect (just below) to kick in
"let g:sclangTerm = "xterm -e"

"if setting is blank, this code checks for popular terminals:
if g:sclangTerm == ""
  if has('mac') || has('macunix')
    "the following has worked with osx
    let g:sclangTerm = "open -a /Applications/Utilities/Terminal.app"
    let g:sclangPipeApp = "/usr/local/bin/sclangpipe_app"
    " on debians (inc ubuntu) this 'alternatives' entry should point to the user's preferred term
  else
    for termcmd in ["/etc/alternatives/x-terminal-emulator", "xterm", "urxvtcd", "rxvt"]
      if executable(termcmd)
        let g:sclangTerm = termcmd . " -e"
        break
      endif
    endfor
  endif
  if g:sclangTerm == ""
    echo "scvimrc warning: unable to detect terminal program, hoping xterm exists"
    let g:sclangTerm = "xterm -e"
  endif
endif

"this indicates the location to create a pipe for vim to communicate with
"sclang
"defaults /tmp/sclang-pipe
"let g:sclangPipeLoc = "/tmp/sclang-pipe"

"this indicates a file where the process id for sclangpipe_app is stored
"default /tmp/sclangpipe_app-pid
"let g:sclangPipeAppPidLoc = "/tmp/sclangpipe_app-pid"

" Set to 1 to split scvim and sclang output when running in tmux or
" screen vertically, 0 for horizontally
let g:scvimSplitVertical = 1

" Set the size of the sclang output split in lines or blocks (applies only to
" scvim opened in screen or tmux). Applies vertically or horizontally, depending on
" g:scvimSplitVertical
let g:scvimSplitSize = 25


au BufWinEnter,BufNewFile,BufRead *.sc set filetype=supercollider
au BufWinEnter,BufNewFile,BufRead *.sc let &iskeyword="@,48-57,_,192-255" | runtime ftplugin/supercollider.vim
au BufWinEnter,BufNewFile,BufRead *.sc set sw=4 ts=4 autoindent "this line can be changed however you like

"sc help files
au BufWinEnter,BufNewFile,BufRead *.scd set filetype=supercollider
au BufWinEnter,BufNewFile,BufRead *.scd let &iskeyword="@,48-57,_,192-255,-,|" | runtime ftplugin/supercollider.vim
au BufWinEnter,BufNewFile,BufRead *.scd set sw=4 ts=4 autoindent "this line can be changed however you like

"required for matching
au Filetype supercollider,supercollider_help let b:match_skip = 's:scComment\|scString\|scSymbol'
au Filetype supercollider,supercollider_help let b:match_words = '(:),[:],{:}'

"indenting if you want it
"au BufEnter,BufWinEnter,BufNewFile,BufRead *.sc runtime indent/sc_indent.vim


"supercollider vim keybindings
"expand('<cword>') gives current word under cursor without having to yank

au Filetype supercollider,supercollider_help nmap <buffer> K :call SChelp(expand('<cword>'))<CR>
au Filetype supercollider,supercollider_help imap <buffer>  :call SChelp(expand('<cword>'))<CR>
au Filetype supercollider,supercollider_help nmap <buffer>  :call SCdef(expand('<cword>'))<CR>
au Filetype supercollider,supercollider_help imap <buffer>  :call SCdef(expand('<cword>'))<CR>
au Filetype supercollider,supercollider_help nmap <buffer> <F1> :call HelpBrowser(expand('<cword>'))<CR>
au Filetype supercollider,supercollider_help imap <buffer> <F1> :call HelpBrowser(expand('<cword>'))<CR>a
au Filetype supercollider,supercollider_help vmap <buffer> <F1> :call HelpBrowser(expand('<cword>'))<CR>
au Filetype supercollider,supercollider_help nmap <buffer> <F5> :call SClang_block()<CR>
au Filetype supercollider,supercollider_help imap <buffer> <F5> :call SClang_block()<CR>a
au Filetype supercollider,supercollider_help vmap <buffer> <F5> :call SClang_send()<CR>
au Filetype supercollider,supercollider_help vmap <buffer> <F6> :call SClang_send()<CR>
au Filetype supercollider,supercollider_help nmap <buffer> <F6> :call SClang_send()<CR>
au Filetype supercollider,supercollider_help imap <buffer> <F6> :call SClang_send()<CR>a
au Filetype supercollider,supercollider_help nmap <buffer> <F7> :call SClang_TempoClock_clear()<CR>
au Filetype supercollider,supercollider_help imap <buffer> <F7> :call SClang_TempoClock_clear()<CR>a
au Filetype supercollider,supercollider_help nmap <buffer> <F8> :call SClang_free("s")<CR>
au Filetype supercollider,supercollider_help imap <buffer> <F8> :call SClang_free("s")<CR>a
au Filetype supercollider,supercollider_help nmap <buffer> <F12> :call SClang_thisProcess_stop()<CR>
au Filetype supercollider,supercollider_help imap <buffer> <F12> :call SClang_thisProcess_stop()<CR>a

"end of scvim (supercollider vim)
