-
Notifications
You must be signed in to change notification settings - Fork 172
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
Application sessions: restoring application state #1026
Comments
I don't have any plans to implement this feature soon... However, it looks like you've put some thought and research into this; feel free to open a Pull Request! If you can provide a clean and simple implementation, I will gladly provide guidance, review code, and merge it. My potential hesitance/concerns:
|
@jgehrig Hi, thanks! I will consider to do this at some point for sure. We have had this feature in QT apps running under KDE DE for many years. It's been default X11-builtin for ages, take a look: X session manager. KDE folks even have implemented X.org's session server namely
I think this could be as simple as a few commands restoring opened files. It doesn't require anything sofisticated.
Qt provides a guideline on sessions implementation and they have this feature built-in into their framework. It doesn't provide it for Windows systems though because Windows doesn't have session manager like X11 or KDE do so it's going to be excluded anyway. Upd: see list of plugins for session management below |
Instead of trying to capture all details about what state needs to be saved, why not defer to the neovim configuration to handle the details. After all neovim has mechanisms for storing sessions (mksession) and preserve work data (swap-file, shada). And there are probably too many corner cases to address on our side (should you call From the Qt docs these are the supported signals, commitDataRequest
I think this is usually implemented as a popup dialog for the user to confirm/cancel shutdown. saveStateStateRequest
sounds a lot like swap-file. QGuiApplication::isSessionRestored()/sessionId() The session manager also provides a unique id so the application can, for example, save unique filenames on exit and restore them on startup. RFCInstead of trying to determine which context should be saved (or not), it is better to passthrough these calls to user callback functions (vimscript/lua) and allow those to handle the events. For implementation purposes:
As an uninspired example, the user could
Caveats
A better place to read on session management is probably X11 docs https://www.x.org/releases/X11R7.7/doc/libSM/xsmp.html. In addition Vim has an implementation for X11 but I think it does not implement restart/discard commands. |
@equalsraf I agree, the native
Yeah, nvim's native Plugins list to manage sessionsA few weeks ago I've found there are plugins to manage sessions for neovim, some of them hook into neovim events and save sessions upon exit (i.e. olimorris/persisted), checkout: |
An autocmd would work for saveStateStateRequest. But not for commitDataRequest because it may need to return data (cancelation). But maybe it is best to skip implementing commitDataRequest for starters. For saveStateStateRequest m_nvim->api0()->vim_command("doautocmd User GuiSessionSaveRequest"); and another for restoring the session startup Also need a way to expose the session id, like a global var |
@equalsraf Yup. Passing upd: currently, for |
Please read about QT Sessions here and here. This is more broad topic on user sessions in X11 systems on Linux platforms.
I request to make it possible for neovim-qt to automatically save the application state when the system is shut down and replicate it when it starts up so I don't have to run everytime the same commands.
Related issue:
The text was updated successfully, but these errors were encountered: