Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ The following variables are available for configuration in your `.vimrc` file:
| `g:scFlash` | Highlighting of evaluated code | `0` |
| `g:scSplitDirection` | Default window orientation when using a terminal multiplexer | `"h"` |
| `g:scSplitSize` | Post window size (% of screen) when using a terminal multiplexer | `50` |
| `g:scTerminalBuffer` | If set to `"on"` use vim's `:term` to launch `g:sclangTerm` | `"off"` |

Example `.vimrc` line for gnome-terminal users:

Expand Down
45 changes: 39 additions & 6 deletions ftplugin/supercollider.vim
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ if exists("g:scSplitSize")
let s:scSplitSize = g:scSplitSize
endif


let s:scTerminalBuffer = "off"
if exists("g:scTerminalBuffer")
let s:scTerminalBuffer = g:scTerminalBuffer
endif

" ========================================================================================

function! FindOuterMostBlock()
Expand Down Expand Up @@ -219,13 +225,39 @@ endfunction

let s:sclangStarted = 0

function s:TerminalEnabled()
return exists(":term") && (s:scTerminalBuffer == "on")
endfunction

function s:KillSClangBuffer()
if bufexists(bufname('start_pipe'))
exec 'bd! start_pipe'
endif
endfunction

function SClangStart(...)
let l:tmux = exists('$TMUX')
let l:screen = exists('$STY')
if l:tmux || l:screen
let l:splitDir = (a:0 == 2) ? a:1 : s:scSplitDirection
let l:splitSize = (a:0 == 2) ? a:2 : s:scSplitSize

let l:splitDir = (a:0 == 2) ? a:1 : s:scSplitDirection
let l:splitSize = (a:0 == 2) ? a:2 : s:scSplitSize
if s:TerminalEnabled()
let l:term = ":term "
if !has("nvim")
let l:term .= "++curwin ++close "
endif
let l:isVertical = l:splitDir == "v"
let l:splitCmd = (l:isVertical) ? "vsplit" : "split"
let l:resizeCmd = (l:isVertical) ? "vertical resize " : "resize "
vsplit
wincmd w
call s:KillSClangBuffer()
exec "vertical resize " .(l:splitSize * 2) ."%"
exec "set wfw"
exec "set wfh"
exec l:term .s:sclangPipeApp
exec "normal G"
wincmd w
elseif l:tmux || l:screen
if l:tmux
let l:cmd = "tmux split-window -" . l:splitDir . " -p " . l:splitSize . " ;"
let l:cmd .= "tmux send-keys " . s:sclangPipeApp . " Enter ; tmux select-pane -l"
Expand All @@ -241,16 +273,17 @@ function SClangStart(...)
call system("screen -S " . l:screenName . " -X resize " . l:splitSize . '%')
call system("screen -S " . l:screenName . " -X bindkey -k k5")
endif

else
call system(s:sclangTerm . " " . s:sclangPipeApp . "&")
endif

let s:sclangStarted = 1
endfunction

function SClangKill()
call system(s:sclangDispatcher . " -q")
if has("nvim")
call s:KillSClangBuffer()
endif
endfunction

function SClangKillIfStarted()
Expand Down