Skip to content

Commit bb21f4d

Browse files
committed
feature: add support for folke/persistence.nvim plugin
1 parent cff343c commit bb21f4d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

strategies/nvim_session.sh

+9
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ original_command_contains_session_flag() {
1515
[[ "$ORIGINAL_COMMAND" =~ "-S" ]]
1616
}
1717

18+
persistence_nvim_plugin_exists() {
19+
nvim --headless -c 'lua if not pcall(require, "persistence") then os.exit(1) end' -c 'qa'
20+
[ $? -ne 1 ]
21+
}
22+
1823
main() {
1924
if nvim_session_file_exists; then
2025
echo "nvim -S"
@@ -23,6 +28,10 @@ main() {
2328
# session flag `-S`. This will cause an error, so we're falling back to
2429
# starting plain nvim.
2530
echo "nvim"
31+
elif persistence_nvim_plugin_exists; then
32+
# Load folke's persistence.nvim sessions. And Shoutout to ThePrimeagen and TjDevries.
33+
# Also Shoutout to my favorite youtuber Mr. Hussein Nasser because I'm learning a lot from you.
34+
echo "nvim -c 'lua require(\"persistence\").load()'"
2635
else
2736
echo "$ORIGINAL_COMMAND"
2837
fi

0 commit comments

Comments
 (0)