mirror of
				https://github.com/tmux-plugins/tmux-resurrect.git
				synced 2025-11-04 08:56:03 +00:00 
			
		
		
		
	Support for restoring neovim sessions
This commit is contained in:
		@@ -1,6 +1,7 @@
 | 
			
		||||
# Changelog
 | 
			
		||||
 | 
			
		||||
### master
 | 
			
		||||
- add support for restoring neovim sessions
 | 
			
		||||
 | 
			
		||||
### v1.4.0, 2014-10-25
 | 
			
		||||
- plugin now uses strategies when fetching pane full command. Implemented
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										21
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								README.md
									
									
									
									
									
								
							@@ -12,7 +12,7 @@ projects.
 | 
			
		||||
can be completely restored after a system restart (or when you feel like it).
 | 
			
		||||
No configuration is required. You should feel like you never quit tmux.
 | 
			
		||||
 | 
			
		||||
It even (optionally) [restores vim sessions](#restoring-vim-sessions)!
 | 
			
		||||
It even (optionally) [restores vim and neovim sessions](#restoring-vim-and-neovim-sessions)!
 | 
			
		||||
 | 
			
		||||
### Screencast
 | 
			
		||||
 | 
			
		||||
@@ -44,8 +44,8 @@ This plugin goes to great lengths to save and restore all the details from your
 | 
			
		||||
- active pane for each window
 | 
			
		||||
- programs running within a pane! More details in the
 | 
			
		||||
  [configuration section](#configuration).
 | 
			
		||||
- restoring vim sessions (optional). More details in
 | 
			
		||||
  [restoring vim sessions](#restoring-vim-sessions).
 | 
			
		||||
- restoring vim/neovim sessions (optional). More details in
 | 
			
		||||
  [restoring vim and neovim sessions](#restoring-vim-and-neovim-sessions).
 | 
			
		||||
- restoring bash history (optional, *experimental*). More details in
 | 
			
		||||
  [restoring bash history](#restoring-bash-history-experimental).
 | 
			
		||||
 | 
			
		||||
@@ -88,7 +88,7 @@ You should now be able to use the plugin.
 | 
			
		||||
Configuration is not required, but it enables extra features.
 | 
			
		||||
 | 
			
		||||
Only a conservative list of programs is restored by default:<br/>
 | 
			
		||||
`vi vim emacs man less more tail top htop irssi`.
 | 
			
		||||
`vi vim nvim emacs man less more tail top htop irssi`.
 | 
			
		||||
 | 
			
		||||
- Restore additional programs with the setting in `.tmux.conf`:
 | 
			
		||||
 | 
			
		||||
@@ -115,15 +115,20 @@ Only a conservative list of programs is restored by default:<br/>
 | 
			
		||||
 | 
			
		||||
        set -g @resurrect-processes ':all:'
 | 
			
		||||
 | 
			
		||||
#### Restoring vim sessions
 | 
			
		||||
#### Restoring vim and neovim sessions
 | 
			
		||||
 | 
			
		||||
- save vim sessions. I recommend [tpope/vim-obsession](https://github.com/tpope/vim-obsession).
 | 
			
		||||
- save vim/neovim sessions. I recommend
 | 
			
		||||
  [tpope/vim-obsession](https://github.com/tpope/vim-obsession) (as almost every
 | 
			
		||||
  plugin, it works for both vim and neovim).
 | 
			
		||||
- in `.tmux.conf`:
 | 
			
		||||
 | 
			
		||||
        # for vim
 | 
			
		||||
        set -g @resurrect-strategy-vim 'session'
 | 
			
		||||
        # for neovim
 | 
			
		||||
        set -g @resurrect-strategy-nvim 'session'
 | 
			
		||||
 | 
			
		||||
`tmux-resurrect` will now restore vim sessions if `Sessions.vim` file is
 | 
			
		||||
present.
 | 
			
		||||
`tmux-resurrect` will now restore vim and neovim sessions if `Sessions.vim` file
 | 
			
		||||
is present.
 | 
			
		||||
 | 
			
		||||
#### Resurrect save dir
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,7 @@ restore_option="@resurrect-restore"
 | 
			
		||||
 | 
			
		||||
# default processes that are restored
 | 
			
		||||
default_proc_list_option="@resurrect-default-processes"
 | 
			
		||||
default_proc_list='vi vim emacs man less more tail top htop irssi'
 | 
			
		||||
default_proc_list='vi vim nvim emacs man less more tail top htop irssi'
 | 
			
		||||
 | 
			
		||||
# User defined processes that are restored
 | 
			
		||||
#  'false' - nothing is restored
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										30
									
								
								strategies/nvim_session.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										30
									
								
								strategies/nvim_session.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,30 @@
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
 | 
			
		||||
# "nvim session strategy"
 | 
			
		||||
#
 | 
			
		||||
# Same as vim strategy, see file 'vim_session.sh'
 | 
			
		||||
 | 
			
		||||
ORIGINAL_COMMAND="$1"
 | 
			
		||||
DIRECTORY="$2"
 | 
			
		||||
 | 
			
		||||
nvim_session_file_exists() {
 | 
			
		||||
	[ -e "${DIRECTORY}/Session.vim" ]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
original_command_contains_session_flag() {
 | 
			
		||||
	[[ "$ORIGINAL_COMMAND" =~ "-S" ]]
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
main() {
 | 
			
		||||
	if nvim_session_file_exists; then
 | 
			
		||||
		echo "nvim -S"
 | 
			
		||||
	elif original_command_contains_session_flag; then
 | 
			
		||||
		# Session file does not exist, yet the original nvim command contains
 | 
			
		||||
		# session flag `-S`. This will cause an error, so we're falling back to
 | 
			
		||||
		# starting plain nvim.
 | 
			
		||||
		echo "nvim"
 | 
			
		||||
	else
 | 
			
		||||
		echo "$ORIGINAL_COMMAND"
 | 
			
		||||
	fi
 | 
			
		||||
}
 | 
			
		||||
main
 | 
			
		||||
		Reference in New Issue
	
	Block a user