numToStr / FTerm.nvim

:fire: No-nonsense floating terminal plugin for neovim :fire:
MIT License
721 stars 24 forks source link

feat: `auto_close` #29

Closed numToStr closed 2 years ago

numToStr commented 2 years ago

By default, FTerm closes the terminal buffer as soon as the shell or command exists and there is no way to override this behavior.

This PR provides an option i.e. auto_close to override that behavior and prevents buffer from closing. FWIW this is also the neovim's default behavior for terminals.

Fixes #18

jonathf commented 2 years ago

As missing values in lua results in nil value, this patch makes t:setup() result in close_to_kill=true while t:setup{ border = "single" } will result in close_to_kill=false.

I think you should either invert your variables meaning and renaming to something like no_autoclose, or accept that in this context nil means true.

numToStr commented 2 years ago

@jonathf Nice catch. I've now fixed that bug.

But there is still one big issue with this that there is no way to clear the stored window and terminal buffer handle when shells exit after [Process exited 0] message. And for some reason, nvim_buf_is_valid returns true for the buffer id. I am still working on how to fix this.

jonathf commented 2 years ago

I am not sure if I follow. Can't the user just manually trigger t:close(true)?

numToStr commented 2 years ago

Can't the user just manually trigger t:close(true)?

Yes, they can but it is not exposed to the user for the default terminal.

I'll rethink about the implementation once again considering #33. As I also want this feature.

numToStr commented 2 years ago

@bigjazzsound @jonathf I fixed some bugs from last time and I think It is now good to go. Please let me know If everything is working as expected.

Edit: One thing I changed is the config which is auto_close rather than close_on_kill

numToStr commented 2 years ago

I am going to merge this for now. If you face any problem please feel free to report issues.

ilan-schemoul commented 2 weeks ago

@jonathf Nice catch. I've now fixed that bug.

But there is still one big issue with this that there is no way to clear the stored window and terminal buffer handle when shells exit after [Process exited 0] message. And for some reason, nvim_buf_is_valid returns true for the buffer id. I am still working on how to fix this.

Is it normal I still have process exited 0 when I quit lazygit ? Is it because I use fish ?