Open norogoth opened 2 years ago
Important! I found that this is happening because tmux relies on files in /tmp
that are being deleted on restart.
I'm having this issue
Do not use appimage
to fix this problem.
chmod +x /home/user/Apps/nvim-linux64/bin/nvim
sudo ln -s /home/user/Apps/nvim-linux64/bin/nvim /usr/local/bin/nvim
-- Be careful to complete the nvim
executable file path.I have the following similar error. Opened a nvim session in nvim. All fine.
I kill tmux sessions with kill-session as you can see (it's the same as restarting the computer):
I open it with tmux resurrect and I got this:
So as you can see, it appears that the nvim session got restored, but it's just text. there is a terminal session above and that's all i can do. I can't write in nvim session
All i can do is clear the terminal.which is the same that no getting nvim session restored. any help?
@SamuelCano03 did you find a solution for this?
@SamuelCano03 did you find a solution for this?
I don't remember exactly what I changed, but I ended up with a solution that implies getting nvim sessions restored but without buffers (in other words, you get an empty nvim session) my config related is in https://github.com/SamuelCano03/dotfiles
@SamuelCano03 did you find a solution for this?
I don't remember exactly what I changed, but I ended up with a solution that implies getting nvim sessions restored but without buffers (in other words, you get an empty nvim session) my config related is in https://github.com/SamuelCano03/dotfiles
Thanks for sharing your dotfiles
Hi there,
Did anyone end up figuring this one out?
With neovim, the sessions open up blank after PC restart, rather than having the files open.
I have the NVIM stuff setup as per the Resurrect GITHUB:
set -g @resurrect-strategy-vim 'session' set -g @resurrect-strategy-nvim 'session' set -g @resurrect-capture-pane-contents 'on' set -g @resurrect-dir '~/.tmux/envs' set -g @continuum-restore 'on'
Ok, I've realised that the specific issue is that TMUX Resurrect is quite limited for Neovim, in that it only will resurrect the files if one opened the relevant file from terminal like ':nvim my_file' , rather than restoring the actual buffers that were open once within neovim.
TLDR: If one opens Neovim, and then opens a file via Telescope or similar, it only reloads 'Neovim', rather than the file.
Ok for anyone who ran into this issue (a lot by a net search?), I developed a custom solution to this which works perfectly. I'm sure something could be adapted for use within the plugin, however at the moment I'm using my Vimscript config and that would need to migrate to the library for appropriate loading. Additionally, I'm not a massive fan of:
How it works:
if empty(getenv('TMUX'))
Plug 'romgrk/barbar.nvim'
endif
... on each bit of barbar.nvim config, then just mapping the equivalent commands in Tmux so that there's no context switching needed. That way, when not using TMUX, one gets Barbar, otherwise the full throttle.
SOLUTION:
" Nvim Session loader for TMUX.
function! ConstructNvimSessionFileName()
let session_id_raw = substitute(system('tmux display-message -p "#{session_id}"'), '\n', '', '')
let session_id = substitute(session_id_raw, '^\$', '', '')
let window_index = substitute(system('tmux display-message -p "#{window_index}"'), '\n', '', '')
let pane_index = substitute(system('tmux display-message -p "#{pane_index}"'), '\n', '', '')
return getcwd() . '/.TmuxNvimSession-' . session_id . '-' . window_index . '-' . pane_index . '.vim'
endfunction
function! StartTmuxPaneNvimSession()
if exists("$TMUX_PANE")
let session_file = ConstructNvimSessionFileName()
"echo 'Attempting to load Tmux Pane Nvim Session from ' . session_file
if filereadable(session_file)
execute 'source ' . session_file
echo "Loading Session from " . session_file
endif
execute 'Obsession ' . session_file
echo "Saving Session to " . session_file
" Reload buffer to re-enable syntax highlighting and a few issues
call timer_start(100, {tid -> execute("bufdo if !empty(expand('%')) | e | endif")})
endif
endfunction
if exists('$TMUX')
autocmd VimEnter * call StartTmuxPaneNvimSession()
endif
#!/usr/bin/env bash
# "nvim session strategy"
#
# Same as vim strategy, see file 'vim_session.sh'
#
# Adapted to work with hidden session files named after Tmux pane IDs
ORIGINAL_COMMAND="$1"
DIRECTORY="$2"
# Fetch current Tmux session, window, and pane identifiers
get_tmux_identifiers() {
local session_id_raw=$(tmux display-message -p "#{session_id}")
# Remove the dollar sign from the session ID
local session_id=${session_id_raw#\$}
local window_index=$(tmux display-message -p "#{window_index}")
local pane_index=$(tmux display-message -p "#{pane_index}")
echo "${session_id}-${window_index}-${pane_index}"
}
# Check if a specific Neovim session file exists
nvim_session_file_exists_for_identifiers() {
local identifiers=$(get_tmux_identifiers)
[ -e "${DIRECTORY}/.TmuxNvimSession-${identifiers}.vim" ]
}
nvim_session_file_exists() {
[ -e "${DIRECTORY}/Session.vim" ]
}
original_command_contains_session_flag() {
[[ "$ORIGINAL_COMMAND" =~ "-S" ]]
}
main() {
if nvim_session_file_exists_for_identifiers; then
local identifiers=$(get_tmux_identifiers)
echo "nvim -S ${DIRECTORY}/.TmuxNvimSession-${identifiers}.vim"
elif 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
Let me know if this helps anyone!
I am on Debian 11 using tmux-ressurect with neovim .5. All files are edited through SSHFS. However this happens with files that are only local. If I save the session, close the terminal window, reopen terminal and tmux and resurrect, then all my panes and vim sessions within open up without issue. However, if I restart my computer, then when I open tmux and resurrect, I get all my panes and windows, but I have each pane set to the last dir but no neovim sessions are actually open. This adds a considerable amount of time to my work as I have to hunt down each and every file again versus just hitting the ground running every day.
Thank you very much for your assistance on this important issue and thank you for this very useful plugin.
.tmux.conf - https://pastebin.com/mC9ZSsad last - https://pastebin.com/2DtEQ9MW