Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically hide terminal on exiting terminal mode #4

Closed
LordMZTE opened this issue May 14, 2022 · 6 comments
Closed

Automatically hide terminal on exiting terminal mode #4

LordMZTE opened this issue May 14, 2022 · 6 comments

Comments

@LordMZTE
Copy link

I think it would be really handy to have the option to make a terminal close automatically once the terminal mode is exited. That way, if only one command should be ran, there'd be no need to manually toggle the terminal again, and it will simply hide once terminal mode is exited.

@itmecho
Copy link
Owner

itmecho commented May 14, 2022

Can you clarify exactly what you mean? Do you mean that once the command you sent with NeotermRun finishes, automatically hide the terminal window, or do you mean when the terminal exits, i.e. typing exit in the terminal?

@LordMZTE
Copy link
Author

When neoterm is toggled, nvim will go into terminal mode (basically insert mode for terminals). If the user goes back to normal mode, the buffer will stay visible. My suggestion is that the buffer will be hidden instead.

@itmecho
Copy link
Owner

itmecho commented May 28, 2022

So you're in terminal mode and you hit <C-\><C-n> and you'd like that to toggle the Neoterm window?

@LordMZTE
Copy link
Author

LordMZTE commented Jun 1, 2022

Exactly!

@itmecho
Copy link
Owner

itmecho commented Jun 14, 2022

OK, I've just pushed a commit that triggers custom autocommands which you should be able to use to achieve what you want! You should just need to add something like this:

autocmd User NeotermTermLeave NeotermClose

or

vim.api.nvim_create_autocmd("User", {
  pattern = "NeotermTermLeave",
  callback = require('neoterm').close,
})

Let me know if that works!

@LordMZTE
Copy link
Author

Works perfectly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants