Skip to content

Commit

Permalink
feat: new command to edit session files
Browse files Browse the repository at this point in the history
  • Loading branch information
mike325 committed Oct 28, 2024
1 parent 21eeb68 commit e68e9f4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
11 changes: 0 additions & 11 deletions get_nvim.log

This file was deleted.

28 changes: 28 additions & 0 deletions lua/configs/mini.lua
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,34 @@ if mini.sessions then
end
end, { bang = true, nargs = '?', complete = completions.session_files })

nvim.command.set('SessionEdit', function(opts)
local session = opts.args

local function edit_sessions_file(session_name)
local session_file = sessions_dir .. '/' .. session_name
if not is_file(session_file) then
vim.notify('Invalid Session: ' .. session_name, vim.log.levels.ERROR, { title = 'mini.session' })
return
end
vim.cmd.edit(session_file)
end

if session == '' then
local sessions = require('utils.files').get_files(sessions_dir)
vim.ui.select(
vim.tbl_map(vim.fs.basename, sessions),
{ prompt = 'Select session file: ' },
vim.schedule_wrap(function(choice)
if choice then
edit_sessions_file(choice)
end
end)
)
else
edit_sessions_file(session)
end
end, { bang = true, nargs = '?', complete = completions.session_files })

nvim.command.set('SessionDelete', function(opts)
local bang = opts.bang
local session = opts.args
Expand Down

0 comments on commit e68e9f4

Please sign in to comment.