mirror of
https://github.com/ThePrimeagen/harpoon.git
synced 2025-07-13 17:40:25 +00:00
commit
346e271800
@ -12,7 +12,7 @@ fun! GotoBuffer(ctrlId)
|
||||
let contents = g:win_ctrl_buf_list[a:ctrlId]
|
||||
if type(l:contents) != v:t_list
|
||||
" Create the terminal
|
||||
terminal
|
||||
exe has("nvim") ? "terminal" : "terminal ++curwin"
|
||||
call SetBuffer(a:ctrlId)
|
||||
end
|
||||
let contents = g:win_ctrl_buf_list[a:ctrlId]
|
||||
@ -21,11 +21,19 @@ fun! GotoBuffer(ctrlId)
|
||||
end
|
||||
|
||||
let bufh = l:contents[1]
|
||||
call nvim_win_set_buf(0, l:bufh)
|
||||
if !bufexists(bufh)
|
||||
" Create the terminal
|
||||
exe has("nvim") ? "terminal" : "terminal ++curwin"
|
||||
call SetBuffer(a:ctrlId)
|
||||
endif
|
||||
|
||||
let contents = g:win_ctrl_buf_list[a:ctrlId]
|
||||
let bufh = l:contents[1]
|
||||
exe "b" . l:bufh
|
||||
endfun
|
||||
|
||||
fun! SetBuffer(ctrlId)
|
||||
if has_key(b:, "terminal_job_id") == 0
|
||||
if &buftype != "terminal"
|
||||
echo "You must be in a terminal to execute this command"
|
||||
return
|
||||
end
|
||||
@ -34,7 +42,7 @@ fun! SetBuffer(ctrlId)
|
||||
return
|
||||
end
|
||||
|
||||
let g:win_ctrl_buf_list[a:ctrlId] = [b:terminal_job_id, nvim_win_get_buf(0)]
|
||||
let g:win_ctrl_buf_list[a:ctrlId] = [has_key(b:, "terminal_job_id") ? b:terminal_job_id : 0, bufnr()]
|
||||
endfun
|
||||
|
||||
fun! SendTerminalCommand(ctrlId, command)
|
||||
@ -52,10 +60,11 @@ fun! SendTerminalCommand(ctrlId, command)
|
||||
echo "Unable to send command to terminal"
|
||||
end
|
||||
|
||||
let job_id = l:contents[0]
|
||||
call chansend(l:job_id, a:command)
|
||||
if has("nvim")
|
||||
let job_id = l:contents[0]
|
||||
call chansend(l:job_id, a:command)
|
||||
else
|
||||
let bufh = l:contents[1]
|
||||
call term_sendkeys(l:bufh, a:command)
|
||||
endif
|
||||
endfun
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user