I've configured Vim to look like this:
+------------------------------------+
| N | Code |
| E | |
| R | |
| D | |
| T | |
| r |-------------------------------|
| e | REPL |
| e | |
+------------------------------------+
Every element is in it's own buffer. Is it possible to delete the REPL buffer only when I quit the code buffer? If I open and close help, for example, the REPL should stay but when I close the code buffer, the REPL buffer should close as well.
This is what I have now:
let s:code_repl_nrs = {} " A map of (code buffer number) - (REPL buffer number)
let s:last_leaved_buffer_nr = -1 " The number of the last leaved buffer
autocmd BufLeave,BufDelete * let s:last_leaved_buffer_nr = bufnr('%')
autocmd BufUnload * call <SID>StopREPL(s:last_leaved_buffer_nr) " Stop the REPL when closing the code buffer
"" Stops a REPL given the number of the current buffer
function! s:StopREPL(buffer_nr)
let l:repl_nr = get(s:code_repl_nrs, a:buffer_nr . '', -1) " Get the number of the REPL buffer
if l:repl_nr != -1
exec l:repl_nr . 'bdelete!'
endif
endfunction
When I use :h
, the REPL closes. How can I prevent this?