mirror of
https://github.com/iofq/nvim.nix.git
synced 2026-01-23 08:55:16 -06:00
even more jj mini/snacks rice
This commit is contained in:
parent
83f9f90f1f
commit
75c09a73ff
15 changed files with 345 additions and 337 deletions
48
nvim/lua/plugins/lib/session_jj.lua
Normal file
48
nvim/lua/plugins/lib/session_jj.lua
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
local M = {}
|
||||
M.load = function()
|
||||
local jj_root = vim.system({ 'jj', 'workspace', 'root' }):wait()
|
||||
local sessions = require('mini.sessions')
|
||||
|
||||
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*]', ''))
|
||||
local root = vim.trim(string.gsub(jj_root.stdout, '\n', ''))
|
||||
local jj_sesh = string.gsub(string.format('jj:%s:%s', root, branch), '[./]', '-')
|
||||
if jj_sesh ~= '' then
|
||||
vim.opt.shadafile = vim.fn.stdpath('data') .. '/myshada/' .. jj_sesh .. '.shada'
|
||||
for name, _ in pairs(sessions.detected) do
|
||||
if name == jj_sesh then
|
||||
vim.ui.select({
|
||||
'No',
|
||||
'Yes',
|
||||
}, { prompt = 'Session found at ' .. jj_sesh .. ', load it?' }, function(c)
|
||||
if c == 'Yes' then
|
||||
-- load session (buffers, etc) as well as shada (marks)
|
||||
sessions.read(jj_sesh)
|
||||
vim.cmd('rshada')
|
||||
vim.notify('loaded jj session: ' .. jj_sesh)
|
||||
end
|
||||
end)
|
||||
return
|
||||
end
|
||||
end
|
||||
vim.cmd('wshada')
|
||||
sessions.write(jj_sesh)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
Loading…
Add table
Add a link
Reference in a new issue