Skip to content

Commit

Permalink
feat: add a delete function
Browse files Browse the repository at this point in the history
  • Loading branch information
stevearc committed Sep 9, 2022
1 parent 1c350a6 commit 71f45fd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,12 @@
A replacement for `:mksession` with a better API

This is a work in progress

TODO:
- autosave on quit
- periodic saving
- tab-scoped sessions
- hooks for plugins
- window size
- config opts
- documentation
21 changes: 21 additions & 0 deletions lua/resession/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,27 @@ M.list = function()
return ret
end

M.delete = function(name)
local files = require("resession.files")
if not name then
local sessions = M.list()
if vim.tbl_isempty(sessions) then
vim.notify("No saved sessions", vim.log.levels.WARN)
return
end
vim.ui.select(sessions, {}, function(selected)
if selected then
M.delete(selected)
end
end)
return
end
local filename = get_session_file(name)
if not files.delete_file(filename) then
error(string.format("No session '%s'", filename))
end
end

---@param name? string
M.save = function(name)
if not name then
Expand Down

0 comments on commit 71f45fd

Please sign in to comment.