summaryrefslogtreecommitdiff
path: root/fnl/plugins/persistence.fnl
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2024-01-05 01:50:20 +0100
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2024-01-05 01:50:20 +0100
commit2a94573f54c69a9af7536586ab2c03eb88bda5e7 (patch)
tree48e430773d56baef8c751fb8a6b4d76303b61636 /fnl/plugins/persistence.fnl
parent16198ca3bcd0ddd61f8d18280769c6f226b2b7ce (diff)
Refactor
Diffstat (limited to 'fnl/plugins/persistence.fnl')
-rw-r--r--fnl/plugins/persistence.fnl33
1 files changed, 33 insertions, 0 deletions
diff --git a/fnl/plugins/persistence.fnl b/fnl/plugins/persistence.fnl
new file mode 100644
index 0000000..1939564
--- /dev/null
+++ b/fnl/plugins/persistence.fnl
@@ -0,0 +1,33 @@
+;; Session manager.
+
+(local keys [{1 :<leader>sn 2 :<cmd>RestoreSession<cr> :desc "Restore session"}
+ {1 :<leader>se
+ 2 :<cmd>RestoreLastSession<cr>
+ :desc "Restore last session"}
+ {1 :<leader>si
+ 2 :<cmd>IgnoreSession<cr>
+ :desc "Ignore current session"}])
+
+(local user-cmds [[:RestoreSession
+ (lambda []
+ (let [persistence (require :persistence)]
+ (persistence.load)))
+ {:nargs 0}]
+ [:RestoreLastSession
+ (lambda []
+ (let [persistence (require :persistence)]
+ (persistence.load {:last true})))
+ {:nargs 0}]
+ [:IgnoreSession
+ (lambda []
+ (let [persistence (require :persistence)]
+ (persistence.stop)))
+ {:nargs 0}]])
+
+(fn init []
+ (let [cmds (require :util.cmds)]
+ (cmds.create-user-cmds user-cmds)))
+
+(local opts {:options [:buffers :curdir :tabpages :winsize :help]})
+
+{1 :folke/persistence.nvim :event :BufReadPre : init : keys : opts}