nvim-ts-main

This commit is contained in:
iofq 2025-08-19 23:07:48 -05:00
parent ac26b74e43
commit 095e78128b
12 changed files with 195 additions and 413 deletions

View file

@ -55,67 +55,4 @@ function M.status()
}
end
function M.revs()
local function jj_new(picker, item)
picker:close()
if item then
if not item.rev then
vim.notify.warn('No branch or commit found', { title = 'Snacks Picker' })
return
end
local cmd = { 'jj', 'new', '-r', item.rev }
Snacks.picker.util.cmd(cmd, function()
vim.notify('Checking out revision: ' .. item.rev, { title = 'Snacks Picker' })
vim.cmd.checktime()
require('plugins.lib.session_jj').load()
end, { cwd = item.cwd })
end
end
local function jj_rev_cmd(ctx)
if ctx.item.rev then
Snacks.picker.preview.cmd({ 'jj', 'show', '--ignore-working-copy', '--git', '-r', ctx.item.rev }, ctx)
else
ctx.preview:reset()
return 'No preview available.'
end
end
local function jj_log(revset)
if revset == nil then
revset = '-r "ancestors(@,25)"'
else
revset = '-r ' .. revset
end
local status_raw = vim.fn.system(
'jj log --ignore-working-copy '
.. revset
..
' --template \'if(root, format_root_commit(self), label(if(current_working_copy, "working_copy"), concat(separate(" ", self.change_id().shortest(8), self.bookmarks()), " | ", if(empty, label("empty", "(empty)")), if(description, description.first_line(), label(if(empty, "empty"), description_placeholder),),) ++ "\n",),)\''
)
local lines = {}
for line in status_raw:gmatch('[^\r\n]+') do
local sign, rev = string.match(line, '(.)%s(%a+)%s.*')
table.insert(lines, {
text = line,
sign = sign,
rev = rev,
})
end
return lines
end
Snacks.picker.pick {
source = 'jj_revs',
layout = 'ivy',
format = 'text',
title = 'jj log',
items = jj_log(),
confirm = jj_new,
preview = jj_rev_cmd,
}
end
return M