@@ -78,6 +78,12 @@ if exists("g:scSplitSize")
7878 let s: scSplitSize = g: scSplitSize
7979endif
8080
81+
82+ let s: scTerminalBuffer = " off"
83+ if exists (" g:scTerminalBuffer" )
84+ let s: scTerminalBuffer = g: scTerminalBuffer
85+ endif
86+
8187" ========================================================================================
8288
8389function ! FindOuterMostBlock ()
@@ -219,13 +225,39 @@ endfunction
219225
220226let s: sclangStarted = 0
221227
228+ function s: TerminalEnabled ()
229+ return exists (" :term" ) && (s: scTerminalBuffer == " on" )
230+ endfunction
231+
232+ function s: KillSClangBuffer ()
233+ if bufexists (bufname (' start_pipe' ))
234+ exec ' bd! start_pipe'
235+ endif
236+ endfunction
237+
222238function SClangStart (... )
223239 let l: tmux = exists (' $TMUX' )
224240 let l: screen = exists (' $STY' )
225- if l: tmux || l: screen
226- let l: splitDir = (a: 0 == 2 ) ? a: 1 : s: scSplitDirection
227- let l: splitSize = (a: 0 == 2 ) ? a: 2 : s: scSplitSize
228-
241+ let l: splitDir = (a: 0 == 2 ) ? a: 1 : s: scSplitDirection
242+ let l: splitSize = (a: 0 == 2 ) ? a: 2 : s: scSplitSize
243+ if s: TerminalEnabled ()
244+ let l: term = " :term "
245+ if ! has (" nvim" )
246+ let l: term .= " ++curwin ++close "
247+ endif
248+ let l: isVertical = l: splitDir == " v"
249+ let l: splitCmd = (l: isVertical ) ? " vsplit" : " split"
250+ let l: resizeCmd = (l: isVertical ) ? " vertical resize " : " resize "
251+ vsplit
252+ wincmd w
253+ call s: KillSClangBuffer ()
254+ exec " vertical resize " .(l: splitSize * 2 ) ." %"
255+ exec " set wfw"
256+ exec " set wfh"
257+ exec l: term .s: sclangPipeApp
258+ exec " normal G"
259+ wincmd w
260+ elseif l: tmux || l: screen
229261 if l: tmux
230262 let l: cmd = " tmux split-window -" . l: splitDir . " -p " . l: splitSize . " ;"
231263 let l: cmd .= " tmux send-keys " . s: sclangPipeApp . " Enter ; tmux select-pane -l"
@@ -241,16 +273,17 @@ function SClangStart(...)
241273 call system (" screen -S " . l: screenName . " -X resize " . l: splitSize . ' %' )
242274 call system (" screen -S " . l: screenName . " -X bindkey -k k5" )
243275 endif
244-
245276 else
246277 call system (s: sclangTerm . " " . s: sclangPipeApp . " &" )
247278 endif
248-
249279 let s: sclangStarted = 1
250280endfunction
251281
252282function SClangKill ()
253283 call system (s: sclangDispatcher . " -q" )
284+ if has (" nvim" )
285+ call s: KillSClangBuffer ()
286+ endif
254287endfunction
255288
256289function SClangKillIfStarted ()
0 commit comments