remove mini.sessions/jj

This commit is contained in:
iofq 2025-10-05 13:08:24 -05:00
parent 27ce531531
commit 31f7ee21e8
6 changed files with 26 additions and 111 deletions

View file

@ -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

View file

@ -34,7 +34,6 @@ return {
n_lines = 300,
custom_textobjects = {
i = require('mini.extra').gen_ai_spec.indent(),
u = ai.gen_spec.function_call(),
a = ai.gen_spec.treesitter { a = '@parameter.outer', i = '@parameter.inner' },
f = ai.gen_spec.treesitter { a = '@function.outer', i = '@function.inner' },
},
@ -45,24 +44,6 @@ return {
require('mini.surround').setup()
require('mini.splitjoin').setup { detect = { separator = '[,;\n]' } }
require('mini.sessions').setup {
file = '',
autowrite = true,
hooks = {
pre = {
read = function(session) -- load Dart state *before* buffers are loaded
vim.cmd('rshada')
Dart.read_session(session['name'])
end,
write = function(session)
vim.cmd('wshada')
Dart.write_session(session['name'])
end,
},
},
}
require('plugins.lib.session_jj').setup()
local jump = require('mini.jump2d')
jump.setup {
view = { n_steps_ahead = 1, dim = true },