moll / vim-bbye

Delete buffers and close files in Vim without closing your windows or messing up your layout. Like Bclose.vim, but rewritten and well maintained.
http://www.vim.org/scripts/script.php?script_id=4664
Other
654 stars 32 forks source link

Doesn't close neovim terminals #13

Closed languitar closed 6 years ago

languitar commented 6 years ago

Using Bdelete on neovim terminal yields:

Error detected while processing function <SNR>62_bdelete:                                                                                                                                                           
line   48:                                                                                                                                                                                                          
E89: term://.//22038:fish will be killed(add ! to override)

Somehow these should either be killed forcefully by default, or there should be an exclusion to prevent these errors.

moll commented 6 years ago

Hmm, does running :Bdelete! kill it properly?

languitar commented 6 years ago

Yes, that would work. But then I would have to create a mapping that decides whether the current window show a regular file or a terminal.

moll commented 6 years ago

I reckon it'd make sense if only the last line of the error were displayed. I presume that's what happens when you use Vim's built-in :bdelete, too, right?

moll commented 6 years ago

Or NeoVim's native :bdelete, that is.

languitar commented 6 years ago

:bdelete also raises the warning. It's just a bit unintuitive.

moll commented 6 years ago

I think the logic is to trigger that for unsaved files and an open terminal window is considered as such. For cases where it contains unsaved work, perhaps. Regular terminals tend to do the same --- if there's a foreground program running that's not your shell, they tend to warn before closing.

languitar commented 6 years ago

Got around this by using:

function! DeleteBuffer()
    if &buftype ==# 'terminal'
        Bdelete!
    else
        Bdelete
    endif
endfunction
map <leader>q :call DeleteBuffer()<CR>
moll commented 6 years ago

Glad to hear. I'm hesitant to make it the default for the "unsaved data" reasons above though. Maybe NeoVim could instead make :bdelete close without a confirmation if there's no shell subprocess running.

languitar commented 6 years ago

Actually it works that way, but the shell process itself is interpreted as a running child. So probably nothing you can do about that.

moll commented 6 years ago

I don't know how, but I believe Terminal and iTerm2 on the Mac do something that is slightly cleverer than that. IIRC they did seem to warn when closing a terminal with an open ssh connection, for example.