diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3878997..e08cd0b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
diff --git a/README.md b/README.md
index f0a2f99..4006fdc 100644
--- a/README.md
+++ b/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:
-`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:
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
diff --git a/scripts/variables.sh b/scripts/variables.sh
index f6fc88b..4b53985 100644
--- a/scripts/variables.sh
+++ b/scripts/variables.sh
@@ -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
diff --git a/strategies/nvim_session.sh b/strategies/nvim_session.sh
new file mode 100755
index 0000000..4987c68
--- /dev/null
+++ b/strategies/nvim_session.sh
@@ -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