-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: session dir creation question & change cmdline architecture
- Loading branch information
1 parent
9798187
commit 4828b62
Showing
4 changed files
with
108 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,61 @@ | ||
local session = require("session") | ||
local path = require("session.path") | ||
|
||
local M = { | ||
open = function(dir) | ||
local session_file = path.get_session_file(dir) | ||
if vim.fn.filereadable(session_file) then | ||
session.save_session() | ||
session.restore_session(dir) | ||
else | ||
vim.notify(string.format("session file [%s] not exists", session_file), vim.log.levels.ERROR, { title = "Session" }) | ||
end | ||
end, | ||
delete = function(dir) | ||
session.delete_session(dir) | ||
end, | ||
local M = {} | ||
|
||
M = { | ||
open = { | ||
complete = function() | ||
return vim.tbl_map(function(sess) | ||
return sess.work_directory | ||
end, session.get_session_list()) | ||
end, | ||
execute = function(dir) | ||
if dir == nil then | ||
vim.ui.select(session.get_session_list(), { | ||
prompt = "Session open...", | ||
format_item = function(item) | ||
return item.work_directory | ||
end, | ||
}, function(choice) | ||
if choice ~= nil then | ||
M.open.execute(choice.work_directory) | ||
end | ||
end) | ||
return | ||
end | ||
local session_file = path.get_session_file(dir) | ||
if vim.fn.filereadable(session_file) then | ||
session.save_session() | ||
session.restore_session(dir) | ||
else | ||
vim.notify(string.format("session file [%s] not exists", session_file), vim.log.levels.ERROR, { title = "Session" }) | ||
end | ||
end, | ||
}, | ||
delete = { | ||
complete = function() | ||
return vim.tbl_map(function(sess) | ||
return sess.name | ||
end, session.get_session_list()) | ||
end, | ||
execute = function(dir) | ||
if dir == nil then | ||
vim.ui.select(session.get_session_list(), { | ||
prompt = "Session delete...", | ||
format_item = function(item) | ||
return item.work_directory | ||
end, | ||
}, function(choice) | ||
if choice ~= nil then | ||
M.delete.execute(choice.work_directory) | ||
end | ||
end) | ||
return | ||
end | ||
session.delete_session(dir) | ||
end, | ||
}, | ||
} | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters