mirror of
https://github.com/iofq/nvim.nix.git
synced 2026-01-23 08:55:16 -06:00
remove mini.sessions/jj
This commit is contained in:
parent
27ce531531
commit
31f7ee21e8
6 changed files with 26 additions and 111 deletions
|
|
@ -1,70 +0,0 @@
|
|||
local M = {}
|
||||
|
||||
M.setup = function()
|
||||
local id = M.get_id()
|
||||
if M.check_exists(id) then
|
||||
vim.notify('Existing session for ' .. id)
|
||||
end
|
||||
|
||||
vim.keymap.set('n', '<leader>fs', function()
|
||||
M.load()
|
||||
end, { noremap = true, desc = 'mini session select' })
|
||||
end
|
||||
|
||||
M.get_id = function()
|
||||
local jj_root = vim.system({ 'jj', 'workspace', 'root' }):wait()
|
||||
|
||||
if jj_root.code ~= 0 then
|
||||
return
|
||||
end
|
||||
|
||||
local result = vim
|
||||
.system({
|
||||
'jj',
|
||||
'log',
|
||||
'-r',
|
||||
'latest(heads(::@ & bookmarks()))',
|
||||
'--template',
|
||||
'bookmarks',
|
||||
'--no-pager',
|
||||
'--no-graph',
|
||||
})
|
||||
:wait()
|
||||
local branch = vim.trim(string.gsub(result.stdout, '[\n*]', '')) -- trim newlines and unpushed indicator
|
||||
local root = vim.trim(string.gsub(jj_root.stdout, '\n', ''))
|
||||
local id = string.gsub(string.format('jj:%s:%s', root, branch), '[./]', '-') -- slugify
|
||||
return id
|
||||
end
|
||||
|
||||
M.check_exists = function(id)
|
||||
for name, _ in pairs(MiniSessions.detected) do
|
||||
if name == id then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
M.load = function()
|
||||
local id = M.get_id()
|
||||
if id == '' then
|
||||
return
|
||||
end
|
||||
if M.check_exists(id) then
|
||||
vim.ui.select({
|
||||
'Yes',
|
||||
'No',
|
||||
}, { prompt = 'Session found at ' .. id .. ', load it?' }, function(c)
|
||||
if c == 'Yes' then
|
||||
-- load session (buffers, etc) as well as shada (marks)
|
||||
vim.opt.shadafile = vim.fn.stdpath('data') .. '/myshada/' .. id .. '.shada'
|
||||
MiniSessions.read(id)
|
||||
vim.notify('loaded jj session: ' .. id)
|
||||
end
|
||||
end)
|
||||
else
|
||||
MiniSessions.write(id)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
Loading…
Add table
Add a link
Reference in a new issue