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

VimSuspend, VimResume autocmds #3648

Closed
blueyed opened this issue Nov 10, 2015 · 17 comments
Closed

VimSuspend, VimResume autocmds #3648

blueyed opened this issue Nov 10, 2015 · 17 comments
Labels
enhancement feature request
Milestone

Comments

@blueyed
Copy link
Member

blueyed commented Nov 10, 2015

I think it would be useful to have autocommand events for suspending and resuming Neovim (Ctrl-Z, but might be remapped).

This would be useful to indicate to tmux / https://github.com/christoomey/vim-tmux-navigator that the current pane is not controlled by Vim anymore (and restore it).
Ref: christoomey/vim-tmux-navigator#37.

@mhinz
Copy link
Member

mhinz commented Nov 10, 2015

I'm not sure how many use cases there are for it, but then again it should only take a few lines to add these autocmds.

Opinions?

@justinmk
Copy link
Member

What about rasiing FocusGained/FocusLost for resume/suspend?

@justinmk justinmk added the enhancement feature request label Nov 10, 2015
@justinmk justinmk added this to the 0.3 milestone Nov 10, 2015
@ZyX-I
Copy link
Contributor

ZyX-I commented Nov 10, 2015

@justinmk This is logical, but it needs a way to distinguish between “suspend” and “A-Tab” cases since there are different consequences: e.g. with “A-Tab” plugin may start doing some hard job even in a blocking fashion because it knows it has time. With “suspend” it cannot do anything blocking.

@justinmk
Copy link
Member

Ok. I suggest names like VimSuspend/VimResume, for parallel form with VimEnter/VimLeave. All of these states are nearly literal equivalents to OS scheduler states.

@mhinz
Copy link
Member

mhinz commented Nov 10, 2015

👍

@mhinz mhinz self-assigned this Nov 11, 2015
@tarruda
Copy link
Member

tarruda commented Nov 11, 2015

@mhinz better wait until I finish my next PR before working on this. As I said before, I plan to add a lot of flexibility to the TUI, so the kind of hook requested by @blueyed will be simple to add.

@mhinz mhinz removed their assignment Nov 11, 2015
@mhinz
Copy link
Member

mhinz commented Nov 11, 2015

Roger that.

@jeromedalbert
Copy link

I'm not sure how many use cases there are for it

I like Ctrl-Zing, git checkouting another branch (or do some other file modification), and fging back to vim, all within the same terminal.

Just like when I checktime on FocusGained and BufEnter, it would be nice if there was an autocommand for suspending/resuming. Or have suspending/resuming hooked to FocusGained and BufEnter. Even better would be to have the autoread option automatically do all of this.

FYI, for now I am using this workaround:

augroup improved_autoread
  autocmd!
  autocmd FocusGained * silent! checktime
  autocmd BufEnter * silent! checktime
augroup end
noremap <c-z> :suspend<cr>:silent! checktime<cr>

@tomprince
Copy link

When using neomake cargo maker, suspending while a maker is running causes cargo to be unusable outside of vim, since cargo uses a lock to serialize work. It would be nice to be able to kill or otherwise interrupt the process when suspending.

@blueyed
Copy link
Member Author

blueyed commented Dec 30, 2016

@tomprince
You could use a custom mapping like above, which then cancels all cargo jobs.
Please create an issue for Neomake, and we can discuss it from there.

@justinmk
Copy link
Member

Adding this autocmd should be easy, if anyone wants to send a PR.

@zackhsi
Copy link

zackhsi commented Sep 22, 2017

@jeromedalbert thank you for the snippet, works like a charm :)

The silent! does not seem to work though.

@justinmk justinmk changed the title Autocommand for suspending/resuming Neovim VimSuspend, VimResume autocmds Nov 4, 2017
@blueyed
Copy link
Member Author

blueyed commented Feb 24, 2018

@justinmk

Adding this autocmd should be easy, if anyone wants to send a PR.

Please provide some pointers as to where get started with this.

@blueyed
Copy link
Member Author

blueyed commented Feb 24, 2018

I guess though that it makes sense for Vim also, so should likely come in through a patch from there - even if it is likely being done in a different way.

@blueyed
Copy link
Member Author

blueyed commented Feb 24, 2018

Posted at vim_dev about it: https://groups.google.com/d/msg/vim_dev/Gb3D0LCaJrI/Rscj4O9CAgAJ

@felipesere
Copy link

Brief question: how would I check if the current vim instance has support for VimSuspend and VimResume?

@justinmk
Copy link
Member

@felipesere See :help exists().

:echo exists('##VimSuspend')

(Note the double ##.)

For questions about usage/configuration, try https://vi.stackexchange.com and the resources listed at https://neovim.io/community/. The issue tracker is for bugs and feature requests. Thanks.

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

No branches or pull requests

9 participants