From 5da248e40c5e18ce824c173c2e2bf6bc02b94c22 Mon Sep 17 00:00:00 2001 From: JimboKearn Date: Thu, 12 Nov 2020 12:18:56 +0530 Subject: [PATCH] Made this vim compatible --- plugin/harpoon.vim | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/plugin/harpoon.vim b/plugin/harpoon.vim index 8e08de5..5ebaa23 100644 --- a/plugin/harpoon.vim +++ b/plugin/harpoon.vim @@ -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] @@ -23,17 +23,17 @@ fun! GotoBuffer(ctrlId) let bufh = l:contents[1] if !bufexists(bufh) " Create the terminal - 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] - call nvim_win_set_buf(0, l:bufh) + 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 @@ -42,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) @@ -60,6 +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