Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feature: add support for folke/persistence.nvim plugin #534

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions strategies/nvim_session.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ original_command_contains_session_flag() {
[[ "$ORIGINAL_COMMAND" =~ "-S" ]]
}

persistence_nvim_plugin_exists() {
nvim --headless -c 'lua if not pcall(require, "persistence") then os.exit(1) end' -c 'qa'
# shellcheck disable=2181
[ $? -eq 0 ]
}

main() {
if nvim_session_file_exists; then
echo "nvim -S"
Expand All @@ -23,6 +29,10 @@ main() {
# session flag `-S`. This will cause an error, so we're falling back to
# starting plain nvim.
echo "nvim"
elif persistence_nvim_plugin_exists; then
# Load folke's persistence.nvim sessions. And Shoutout to ThePrimeagen and TjDevries.
# Also Shoutout to my favorite youtuber Mr. Hussein Nasser because I'm learning a lot from you.
echo "nvim -c 'lua require(\"persistence\").load()'"
else
echo "$ORIGINAL_COMMAND"
fi
Expand Down