jj file hist

This commit is contained in:
iofq 2025-10-22 01:15:51 -05:00
parent ce017fd37c
commit a004f24728
5 changed files with 100 additions and 33 deletions

View file

@ -30,7 +30,7 @@ cmd({ 'FocusGained', 'TermClose', 'TermLeave' }, {
})
-- Configure difftool buffers
vim.api.nvim_create_autocmd('FileType', {
cmd('FileType', {
pattern = 'qf',
group = vim.api.nvim_create_augroup('difftool', { clear = true }),
callback = function(event)
@ -41,7 +41,7 @@ vim.api.nvim_create_autocmd('FileType', {
local qf = vim.fn.getqflist()
local entry = qf[1]
if not entry or not entry.user_data.diff then
if not entry or not entry.user_data or not entry.user_data.diff then
return nil
end
@ -75,6 +75,32 @@ vim.api.nvim_create_autocmd('FileType', {
end,
})
-- open conflicts in qflist
cmd('BufWinEnter', {
callback = function(event)
if not vim.wo.diff then
return
end
local items = {}
while true do
local found = vim.fn.search('^<<<<<<<', 'W')
if found == 0 then
break
end
local line = vim.api.nvim_buf_get_lines(event.buf, found - 1, found, false)[1]
table.insert(items, { bufnr = event.buf, lnum = found, text = line })
end
if #items > 1 then
vim.fn.setqflist(items, 'r')
vim.schedule(function()
vim.cmd(string.format('%dcopen', math.min(10, #items)))
end)
end
end,
})
-- Init treesitter
cmd('FileType', {
group = vim.api.nvim_create_augroup('treesitter', { clear = true }),